【发布时间】:2022-03-31 14:44:46
【问题描述】:
我们在项目中引入了 cypress 9.3.1 进行 e2e 测试。现在我们面临的问题是我们现有的 jest 测试无法在 CI 中编译。
所有参数化测试都会出现以下错误:
Property 'each' does not exist on type 'TestFunction'.
it.each<TestCase>([
问题:如何解决?
我们尝试过但没有奏效的方法:
-
在每个测试中添加
import { it } from '@jest/globals'。我们可以通过在每个测试中添加import { expect } from '@jest/globals'来解决类似的问题(“断言”类型上不存在属性“toBeTruthy”)。见:https://stackoverflow.com/a/65153905 -
通过将
"exclude": ["cypress/global.d.ts"]添加到tsconfig.spec.json来为 cypress 全局变量添加项目范围的排除项
【问题讨论】:
标签: typescript jestjs dependencies cypress