【发布时间】:2020-03-18 19:29:06
【问题描述】:
我一直在使用react-testing-library 和@testing-library/jest-dom/extend-expect。我昨天安装了 Cypress,现在我的所有玩笑匹配器都出现 Typescript 错误:
Property 'toEqual' doesn't exist on type 'Assertion'. Did you mean 'equal'?
它看起来像是从错误的断言库中获取expect 的类型还是什么?此外,expect(...).to.equal(...) 也不起作用。
我实际上尝试安装@types/jest,yarn 似乎已经成功,但它没有在我的package.json 的devDependencies 中列出。
这是我的tsconfig
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noImplicitAny": false,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": false,
"noEmit": true,
"jsx": "react",
"skipDefaultLibCheck": true,
"types": [
"node",
"cypress",
"jest"
]
},
"include": [
"src"
]
}
我还要提一下,我在 cypress 测试中的所有 cy 调用都从 ESLint 收到 cy is not defined 错误。
【问题讨论】:
标签: typescript jestjs cypress