我一直在使用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,纱线似乎已经成功,但它没有列在我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": …Run Code Online (Sandbox Code Playgroud)