mcpField
T
test

test

github.com/react测试与质量251.7k1.2k 次安装今天更新
代码仓库

关于 test

用于 React 代码库的测试技能,可按指定发布通道运行测试模式,并支持监视模式和 www 变体。

主要功能

  1. 01按发布通道运行测试
  2. 02支持测试模式和标志参数
  3. 03支持 TDD 监视模式
  4. 04报告测试结果与失败项

适用场景

  1. 01在默认通道运行 React 测试
  2. 02检查 experimental 或 stable 构建的测试
  3. 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 标志 = true
  • www - www-modern 通道,VARIANT 标志 = true
  • www variant false - www 通道,VARIANT 标志 = false
  • stable - 发布到 npm 的版本
  • classic - 旧版 www-classic(很少需要)

说明:

  1. 从参数中解析通道(默认:source)
  2. 映射为 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>
  3. 报告测试结果和任何失败项

硬性规则:

  1. 使用 --silent 查看失败项 - 这会将测试输出限制为仅显示失败项。
  2. 使用 --no-watchman - 这是沙盒环境中常见的故障原因。

常见错误:

  • 未指定模式运行 - 会运行所有测试,耗时很长。务必指定模式。
  • 忘记测试两种 www 变体 - 对 __VARIANT__ 标志,需同时测试 www 和 www variant false。
  • 测试意外跳过 - 检查 @gate pragma;请参阅 feature-flags 技能。

评论

支持 Markdown