在 Jest 中,可以通过配置 testPathIgnorePatterns 选项来忽略项目中的特定测试文件。\n\n在 jest.config.js 文件中,添加以下配置:\n\njavascript\nmodule.exports = {\n // other configurations\n testPathIgnorePatterns: [\n "/node_modules/",\n "<rootDir>/path/to/ignored/test.js"\n ]\n};\n\n\n在上面的示例中,testPathIgnorePatterns 配置了两个忽略模式,/node_modules/ 用于忽略 node_modules 目录下的测试文件,<rootDir>/path/to/ignored/test.js 用于忽略指定路径下的测试文件。\n\n这样配置后,Jest 将不会运行被忽略的测试文件。

Jest 单元测试: 如何忽略特定测试文件 (test.js)

原文地址: https://www.cveoy.top/t/topic/pJ60 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录