注意:
tests/webpack-test
主要基于 webpack/test
最初,我们使用以下公式来计算兼容性 passedTestCaseCount / totalTestCount
,totalTestCount = passedTestCaseCount + failedTestCount + skippedTestCount ,但有时由于某些原因(例如,性能、我们不想支持的遗留功能),可能难以与所有 Webpack 测试用例兼容,我们需要一种方法来跳过这些我们不会支持的测试。因此,我们将原始公式调整为 (passedTestCaseCount + willNotSupportTestCount) / totalTestCount
。
目前,我们在每个失败测试用例目录下使用 test.filter.js
来跳过失败的测试用例,使用这种方法可以让我们逐步迁移 Webpack 测试用例,而不会影响实际的兼容性(因为这种方法不会影响真实的 passedTestCaseCount
)。
例如:
当你发现我们通过了一些现在被跳过的失败测试用例时,你可以将 test.filter.js
修改为
或者删除 test.filter.js
基于实现差异和性能考虑,Rspack 将在内部集成一些 Webpack 插件。插件的测试套件也将被复制到 tests/plugin-test
文件夹中,用于测试插件兼容性。
因此,为了与原始仓库保持一致性,不建议修改这些测试用例,除非在以下场景中:
在上述以外的场景中,请遵循 Rspack 测试 指南来添加测试用例。
你可以通过以下方式运行这些测试用例:
./x test plugin
或 pnpm run test:plugin
。rspack/tests/plugin-test
目录下运行 npm run test
。tests/plugin-test
目录下运行 npm run test -- -u
。tests/plugin-test
目录下运行 npm run test -- {args}
。tests/plugin-test/{plugin-name}
文件夹,并将该插件的测试用例复制到该文件夹中。tests/plugin-test/jest.config.js
中的测试配置。如果有特殊配置,请遵循以下步骤:
tests/plugin-test/jest.{plugin-name}.config.js
,导入 jest.config.js
,并根据它进行修改。test:{plugin-name}
命令添加到 tests/plugin-test/package.json
的 scripts
属性中。global.updateSnapshot
来确定是否更新快照。tests/plugin-test/{plugin-name}/README.md
文件,并包含来自测试用例源代码仓库的许可信息。tests/plugin-test/README.md
文件,以包含来自测试用例源代码仓库的链接和署名信息。