相关疑难解决方法(0)

在开玩笑的打字稿中找不到名字

我尝试在react + typescript中为玩笑创建一个初始设置。我已经完成了初始设置并尝试检查测试是否运行。当我使用命令npm test运行测试时,出现以下错误

Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
Run Code Online (Sandbox Code Playgroud)

我已经安装了开玩笑的类型,并删除了tsconfig.json中的类型,但仍然出现相同的错误。

{
  "compilerOptions": {
    "target": "es6",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "plugins": [{ "name": "typescript-tslint-plugin" }],
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",
    "pretty": true,
    "baseUrl": "src",
    "types": ["jest"],
    "typeRoots": ["./src/types"],
    "suppressImplicitAnyIndexErrors": true
  },
  "include": ["src", "node_modules/@types/jest"], …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs jestjs ts-jest

2
推荐指数
7
解决办法
2988
查看次数

标签 统计

jestjs ×1

reactjs ×1

ts-jest ×1

typescript ×1