关于 test
用于 React 代码库的测试技能,可按指定发布通道运行测试模式,并支持监视模式和 www 变体。
主要功能
- 01按发布通道运行测试
- 02支持测试模式和标志参数
- 03支持 TDD 监视模式
- 04报告测试结果与失败项
适用场景
- 01在默认通道运行 React 测试
- 02检查 experimental 或 stable 构建的测试
- 03使用两种变体标志值测试 www 行为
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ react/ react --skill test安装后在 Claude Code 中输入/test确认已加载。
详细介绍
运行 React 代码库的测试。
参数:
- $ARGUMENTS:通道、标志和测试模式
用法示例:
/test ReactFiberHooks- 使用 source 通道运行(默认)/test experimental ReactFiberHooks- 使用 experimental 通道运行/test www ReactFiberHooks- 使用 www-modern 通道运行/test www variant false ReactFiberHooks- 测试 VARIANT=false/test stable ReactFiberHooks- 使用 stable 通道运行/test classic ReactFiberHooks- 使用 www-classic 通道运行/test watch ReactFiberHooks- 以监视模式运行(TDD)
发布通道:
(default)- Source/canary 通道,使用 ReactFeatureFlags.js 默认值experimental- Source/experimental 通道,EXPERIMENTAL 标志 = truewww- www-modern 通道,VARIANT 标志 = truewww variant false- www 通道,VARIANT 标志 = falsestable- 发布到 npm 的版本classic- 旧版 www-classic(很少需要)
说明:
- 从参数中解析通道(默认:source)
- 映射为 yarn 命令:
- (default) →
yarn test --silent --no-watchman <pattern> - experimental →
yarn test -r=experimental --silent --no-watchman <pattern> - stable →
yarn test-stable --silent --no-watchman <pattern> - classic →
yarn test-classic --silent --no-watchman <pattern> - www →
yarn test-www --silent --no-watchman <pattern> - www variant false →
yarn test-www --variant=false --silent --no-watchman <pattern>
- (default) →
- 报告测试结果和任何失败项
硬性规则:
- 使用 --silent 查看失败项 - 这会将测试输出限制为仅显示失败项。
- 使用 --no-watchman - 这是沙盒环境中常见的故障原因。
常见错误:
- 未指定模式运行 - 会运行所有测试,耗时很长。务必指定模式。
- 忘记测试两种 www 变体 - 对
__VARIANT__标志,需同时测试www和www variant false。 - 测试意外跳过 - 检查
@gatepragma;请参阅feature-flags技能。
评论
支持 Markdown