renderHook unable to rerender props on the wrapper
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, react
- Ambito
- documentation
Direzione di ricerca
Inizia confrontando il comportamento attuale del wrapper di renderHook e di rerender con l’esempio di contesto collegato di react-hooks-testing-library. Determina se è possibile aggiornare le props del wrapper o se la documentazione necessita di un’alternativa; il lavoro è completato quando esiste un approccio supportato o una limitazione documentata chiaramente con un esempio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- JavaScript
- Stelle
- 479
- Fork
- 738
- Merge medio
- 5g 1h
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di testing-library/testing-library-docs
-
Broken Chrome Extension Link in Queries DocsForse già presa @rajanpanth l’ha presa 64 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
testing-library/testing-library-docs#1499 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
testing-library/testing-library-docs#1528 ·
I maintainer di solito rispondono entro 4 giorni
-
Framework wrappers and DOM testing libraryForse già presa @jacklaurencegaray l’ha presa 426 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
testing-library/testing-library-docs#1493 · 3 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
testing-library/testing-library-docs#1486 · 1 reazione ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
testing-library/testing-library-docs#1485 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di testing-library/testing-library-docs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
taskcluster/taskcluster#9284 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Xvesa 24bbp incorrect info?Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Spomky-Labs/pwa-bundle#476 ·
-
[feart] 支持 MiMo 类型模型的关闭思考识别Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speced/respec#5504 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno