Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Make wrapper to render configuration available at the global level

未关闭
#1,222 3 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, react
领域
frontend, testing

调研方向

首先定位现有的 configure(...) API 和 render(...) 入口点,然后查看涵盖 render 选项和配置行为的测试。定义全局配置的包装器如何与每次调用的包装器组合,或如何被每次调用的包装器覆盖,并添加测试以展示全局包装器会被应用,同时不会破坏现有的 render 用法。

由索引模型根据 Issue 内容生成。

描述

enhancement needs investigation
Describe the feature you'd like:

When rendering components for test, I often find myself repeating render(ui, { wrapper: TestApp() }) over and over again.

It would be nice to have a possibility to define the wrapper using a global configure(...) call.

By having this in global config, you could ensure that, by default, all the rendered components are tested in the context resembling the onion structure of various wrappers and context providers that they are going to be embedded in in production code anyway. This would help capture bugs when this context layer has an adverse effect on the behaviour of the component under test.

Describe alternatives you've considered:

You could of course define a custom function that does the same for you by wrapping the call to render. However, without the hindsight of defining one upfront, if you've already used the barebones render in hundreds of tests before the need for a wrapper, you need to now refactor all of those tests :(

Teachability, Documentation, Adoption, Migration Strategy:

No migration needed as this would be backwards-compatible in terms of the configure API.

主要语言
JavaScript
星标
19.7k
派生
1.2k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

testing-library/react-testing-library 的其他 Issue

查看 testing-library/react-testing-library 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。