renderHook unable to rerender props on the wrapper
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, react
- Área
- documentation
Línea de trabajo
Comienza comparando el comportamiento actual del wrapper de renderHook y rerender con el ejemplo de contexto de react-hooks-testing-library enlazado. Determina si se pueden actualizar las props del wrapper o si la documentación necesita una alternativa; se considera completado cuando exista un enfoque compatible o una limitación claramente documentada con un ejemplo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Sorry I don't know if I should list this as a bug or as a feature request with the renderHook now being supported react hook testing library. It used to possible to test how context and hooks worked together with react-hooks-testing library - you could render a wrapper with and initial props and then pass new props to the wrapper using rerender.
Here is the example on react hooks testing library site
This was really useful as it allowed you to test how updates from your providers via context could effect the output from your hooks.
To Reproduce Steps to reproduce the behaviour:
This is the implementation as it was on react hooks testing library - I do understand how that how the initial props for the wrapper as changed but I'm using this more to draw attention to how rerender used to work.
import { renderHook, act } from '@testing-library/react-hooks'
import { CounterStepProvider, useCounter } from './counter'
test('should use custom step when incrementing', () => {
const wrapper = ({ children, step }) => (
<CounterStepProvider step={step}>{children}</CounterStepProvider>
)
const { result, rerender } = renderHook(() => useCounter(), {
wrapper,
initialProps: {
step: 2
}
})
act(() => {
result.current.increment()
})
expect(result.current.count).toBe(2)
/**
* For react hook testing library this could be use to update the provider props and therefore affect a hooks return values via context
* in react testing library these values seem to be just passed to the renderHook callback
*/
rerender({ step: 8 })
act(() => {
result.current.increment()
})
expect(result.current.count).toBe(10)
})
Expected behaviour
There should be some way to rerender the wrapper for the hook you are testing with different prop values or maybe a documented example of how to test context and hooks in this way if it already exists. Is this possible with the current implementation?
- 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 63 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 425 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
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Billionmail/BillionMail#389 ·
-
beginner-friendly category:finding-titles community enhancement first-timers-only good first issue hacktoberfest help wanted low hanging fruit micro-contribution type: task up-for-grabs
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
Berserk-hub150/skillhawk#227 · 1 comentario ·
Los mantenedores suelen responder en 8 días
-
Remove responsibilities not working in Custom Roles & BadgesPosiblemente ocupada @thomasgwatson la tomó hoy. Abiertoagent-ready agent:needs-test
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
gkjohnson/three-mesh-bvh#933 ·
-
scope: curriculum status: waiting triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
freeCodeCamp/freeCodeCamp#71076 ·
Los mantenedores suelen responder en 1 día