我有一个create-react-app应用程序,曾经jest用于测试,但我正在慢慢迁移到cypress.
问题是,现在当我运行jest测试时,它包含我的cypress测试并给出错误
ReferenceError: Cypress is not defined
Run Code Online (Sandbox Code Playgroud)
我怎样才能让我的jest(命名约定*.test.js)测试忽略我的cypress测试(通常称为*.spec.js)?
你应该testPathIgnorePatterns在你的笑话配置中使用。
在执行测试之前与所有测试路径匹配的正则表达式模式字符串数组。如果测试路径匹配任何模式,它将被跳过。
开玩笑的配置文件
module.exports = {
// Your normal jest config settings
testPathIgnorePatterns: ["<rootDir>/cypress/"],
}
Run Code Online (Sandbox Code Playgroud)
在您的jest/config.js或任何您有笑话配置(可能是包)的地方,添加以下内容来替换默认的正则表达式以从中查找测试
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$"
Run Code Online (Sandbox Code Playgroud)
到:
"testRegex": "(/__tests__/.*|(\\.|/)(test))\\.[jt]sx?$"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1425 次 |
| 最近记录: |