开玩笑忽略赛普拉斯测试

时间:2020-11-11 18:46:33

标签: jestjs cypress

我有一个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)?

2 个答案:

答案 0 :(得分:6)

您应该在 jest 配置中使用 testPathIgnorePatterns

<块引用>

在执行测试之前与所有测试路径匹配的正则表达式模式字符串数组。如果测试路径与任何模式匹配,则将跳过该路径。

根据Jest config docs

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?$"