ошибка создания реакции приложения - не удается найти имя «описать» - PullRequest
0 голосов
/ 24 февраля 2020

Я использую приложение «создать реагирование» с библиотекой тестирования, и я пытаюсь написать тест, и получил следующую ошибку:

** я увидел Не удается найти имя «описать». Вам нужно установить определения типов для тестового бегуна? . Эта проблема, но я не мог удалить свойство типов, и это также не помогло мне

Cannot find name 'describe'. 
Do you need to install type definitions for a test runner? 
Try `npm i @types/jest` 
or `npm i @types/mocha` 
and then add `jest` or `mocha` to the types field in your tsconfig.

Also tried to put everything in dependencies ... if I run npm test the test is running but I got a lot of errors in the IDE

мой tsconfig. json is:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "types": ["reflect-metadata","node"],
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "strictPropertyInitialization": false,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react",
    "emitDecoratorMetadata": true   
  },
  "include": [
    "src",
    "node_modules/@types/jest"
  ]
}

package. json

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.9.2",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/node": "^12.12.27",
    "@types/react": "^16.9.19",
    "@types/react-dom": "^16.9.0",
    "@types/react-redux": "^7.1.7",
    "@types/react-router": "^5.1.4",
    "@types/redux-logger": "^3.0.7",
    "add": "^2.0.6",
    "axios": "^0.19.2",
    "class-transformer": "^0.2.3",
    "class-validator": "^0.11.0",
    "connected-react-router": "^6.7.0",
    "history": "^4.10.1",
    "immer": "^5.3.4",
    "inversify": "^5.0.1",
    "inversify-react": "^0.4.3",
    "log4js": "^6.1.2",
    "loglevel": "^1.6.7",
    "loglevel-plugin-prefix": "^0.8.4",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-intl": "^3.12.0",
    "react-intl-redux": "^2.2.0",
    "react-redux": "^7.1.3",
    "react-router": "^5.1.2",
    "react-scripts": "3.3.1",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "reflect-metadata": "^0.1.13",
    "typescript": "~3.7.5"
  },
  "devDependencies": {
    "@craco/craco": "^5.6.3",
    "@types/jest": "^24.0.0",
    "@types/react-intl-redux": "^0.1.14",
    "@types/redux-mock-store": "^1.0.2",
    "@typescript-eslint/eslint-plugin": "^2.19.0",
    "@typescript-eslint/parser": "^2.19.0",
    "cross-env": "^7.0.0",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-config-prettier": "^6.10.0",
    "eslint-plugin-import": "^2.20.1",
    "eslint-plugin-jest": "^23.7.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.2",
    "eslint-plugin-react": "^7.18.3",
    "eslint-plugin-react-hooks": "^2.3.0",
    "husky": "^4.2.1",
    "lint-staged": "^10.0.7",
    "prettier": "^1.19.1",
    "redux-mock-store": "^1.5.4"
  },

1 Ответ

0 голосов
/ 24 февраля 2020
then add `jest` or `mocha` to the types field in your tsconfig.

В сообщении об ошибке, полученном при запуске теста, предлагается добавить jest в поле types, но у вас есть только следующее:

"types": ["reflect-metadata","node"],

Измените его на

"types": ["reflect-metadata","node", "jest"],
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...