renderHook unable to rerender props on the wrapper
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, react
调研方向
首先,将当前的 renderHook wrapper 和 rerender 行为与链接的 react-hooks-testing-library context 示例进行比较。确定是否可以更新 wrapper props,或者文档是否需要提供替代方案;存在受支持的方法,或存在附带示例且有明确文档说明的限制,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- JavaScript
- 星标
- 479
- 派生
- 738
- 平均合并
- 5 天 1 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testing-library/testing-library-docs 的其他 Issue
-
Broken Chrome Extension Link in Queries Docs可能已有人在做 @rajanpanth 于 63 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 72/100
testing-library/testing-library-docs#1499 ·
维护者通常 4 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
testing-library/testing-library-docs#1528 ·
维护者通常 4 天内回复
-
Framework wrappers and DOM testing library可能已有人在做 @jacklaurencegaray 于 425 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 38/100
testing-library/testing-library-docs#1493 · 3 条评论 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 55/100
testing-library/testing-library-docs#1486 · 1 个 reaction ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 48/100
testing-library/testing-library-docs#1485 · 1 条评论 ·
维护者通常 4 天内回复
查看 testing-library/testing-library-docs 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
Unsampled pageload span is profiled when profileLifecycle is 'trace' (browser UI profiling)可能已有人在做 @Jxxunnn 今天认领。 未关闭Browser Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 82/100
getsentry/sentry-javascript#25497 · 1 条评论 ·
维护者通常 1 天内回复
-
resource: destroying a resource calls AbortController.abort() without a reason, creating an AbortError with a stack trace each time可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area: core
难度 2/5 1-3 小时 新手友好度 75/100
angular/angular#71422 · 1 条评论 ·
维护者通常 1 天内回复
-
bug status: needs triage
难度 2/5 1-3 小时 新手友好度 72/100
facebook/docusaurus#12739 · 1 条评论 ·
维护者通常 1 天内回复
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
难度 1/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复