相关疑难解决方法(0)

赛普拉斯在玩笑断言中导致类型错误

我一直在使用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.jsondevDependencies.

这是我的 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)

typescript jestjs cypress

24
推荐指数
8
解决办法
1万
查看次数

标签 统计

cypress ×1

jestjs ×1

typescript ×1