Documentation lacks information on createEvent()
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 52/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, react
- Área
- documentation, testing
Línea de trabajo
Comienza revisando la documentación de createEvent() y los ejemplos proporcionados de beforeinstallprompt, incluida la solución provisional con Object.defineProperties. Actualiza la documentación con ejemplos claros y concretos de creación de eventos y verifica que el ejemplo cubra las propiedades de eventos personalizadas y el envío con fireEvent().
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
@testing-library/domversion: latest- Testing Framework and version: jest 26.0.0
- DOM Environment: jsdom latest
Relevant code or config:
import * as React from 'react'
import {render, screen, createEvent, fireEvent, act} from '@testing-library/react'
import {App} from '../index'
test('renders true when event has been fired', async () => {
render(<App />)
await act(async () => {
const event = createEvent('beforeinstallprompt', window, {
userChoice: new Promise((res) =>
res({outcome: 'accepted', platform: ''}),
),
prompt: () => new Promise((res) => res(undefined)),
})
fireEvent(window, event)
})
expect(screen.queryByText(/false/i)).not.toBeInTheDocument()
})
export function App() {
const [eventHeard, setEventHeard] = useState(false)
useEffect(() => {
const evt = (e) => {
e.preventDefault()
setEventHeard(true)
}
window.addEventListener('beforeinstallprompt', evt)
return () => window.removeEventListener('beforeinstallprompt', evt)
})
return <h1>{JSON.stringify(eventHeard)}</h1>
}
What you did:
I was trying to mock the beforeinstallprompt event using createEvent(). The documentation wasn't very clear as to how I create events, so I took a look at the source and it still wasn't clear to me.
What happened:
Reproduction:
Problem description:
Suggested solution:
Update the documentation with examples of exactly how to create events.
Interim solution:
use Object.defineProperties and assign the properties that you need to the object.
const event = createEvent('beforeinstallprompt', window);
Object.defineProperties(event, {
userChoice: {
value: new Promise((res) =>
res({ outcome: 'accepted', platform: '' })
),
},
prompt: { value: () => new Promise((res) => res(undefined)) },
});
fireEvent(window, event);
- Lenguaje dominante
- JavaScript
- Estrellas
- 479
- Forks
- 738
- Merge medio
- 5 d 1 h
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testing-library/testing-library-docs
-
Broken Chrome Extension Link in Queries DocsPosiblemente ocupada @rajanpanth la tomó hace 59 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
testing-library/testing-library-docs#1499 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
testing-library/testing-library-docs#1528 ·
Los mantenedores suelen responder en 4 días
-
Framework wrappers and DOM testing libraryPosiblemente ocupada @jacklaurencegaray la tomó hace 421 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 38/100
testing-library/testing-library-docs#1493 · 3 comentarios ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
testing-library/testing-library-docs#1486 · 1 reacción ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
testing-library/testing-library-docs#1485 · 1 comentario ·
Los mantenedores suelen responder en 4 días
Todos los issues de testing-library/testing-library-docs
Issues similares
-
docs hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
pacocartones/free-llm-api-hub#347 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
cytoscape/cytoscape.js#3536 ·
Los mantenedores suelen responder en 15 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
cuttle-cards/cuttle#1440 ·
Los mantenedores suelen responder en 1 día
-
URL-encoded parser builds nested objects nothing readsPosiblemente ocupada @Senthil455 la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Janani-bn/CivicFix#168 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
code-yeongyu/oh-my-openagent#10172 ·
Los mantenedores suelen responder en 1 día