我有一个adb logcat -p
45678 (the UID of my app)
应用程序,曾经使用create-react-app
进行测试,但是我正在慢慢迁移到jest
。
问题是,现在当我运行cypress
测试时,它包含了jest
测试并给出了错误
cypress
如何使我的ReferenceError: Cypress is not defined
测试(命名约定jest
)忽略我的*.test.js
测试(通常称为cypress
)?
答案 0 :(得分:6)
您应该在 jest 配置中使用 testPathIgnorePatterns
。
在执行测试之前与所有测试路径匹配的正则表达式模式字符串数组。如果测试路径与任何模式匹配,则将跳过该路径。
jest.config.js
module.exports = {
// Your normal jest config settings
testPathIgnorePatterns: ["<rootDir>/cypress/"],
}
答案 1 :(得分:0)
在您的jest/config.js
或您具有最佳配置的任何位置(可能是软件包),添加以下内容以替换默认的正则表达式以从中查找测试
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$"
收件人:
"testRegex": "(/__tests__/.*|(\\.|/)(test))\\.[jt]sx?$"