无法在我的Jest测试文件中导入模块

我正在为一些已编写的服务编写单元测试。我的服务和组件是用Typescript编写的。 我的理解是它无法解析我的打字稿。 我正在单元测试中导入一项这样的服务。我在开玩笑进行单元测试。 没有导入,测试工作正常

我的

package.json

{
  "name": "web",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@date-io/core": "^1.3.6",
    "@material-ui/core": "^4.0.1",
    "@material-ui/icons": "^4.9.1",
    "@testing-library/dom": ">=5",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "7.2.1",
    "@types/jest": "^24.0.0",
    "@types/js-cookie": "^2.2.6",
    "@types/jwt-decode": "^2.2.1",
    "@types/lodash": "^4.14.150",
    "@types/node": "^12.0.0",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@types/react-router-dom": "^5.1.4",
    "@types/reactstrap": "^8.4.2",
    "@types/recharts": "^1.8.9",
    "@typescript-eslint/eslint-plugin": "^2.28.0",
    "@typescript-eslint/parser": "^2.28.0",
    "axios": "^0.19.2",
    "bootstrap": "4.4.1",
    "clsx": "^1.1.0",
    "cross-env": "^7.0.2",
    "eslint": "6.8.0",
    "eslint-config-airbnb": "18.1.0",
    "eslint-config-prettier": "^6.10.1",
    "eslint-plugin-import": "^2.20.1",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-react": "^7.19.0",
    "eslint-plugin-react-hooks": "2.5.0",
    "jquery": "3.0.0",
    "js-cookie": "^2.2.1",
    "jwt-decode": "^2.2.0",
    "lodash": "^4.17.15",
    "material-table": "1.57.2",
    "moment": "^2.24.0",
    "popper.js": "^1.16.0",
    "prettier": "^2.0.4",
    "prop-types": "^15.7.2",
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    "reactstrap": "^8.4.1",
    "recharts": "^1.8.5",
    "typescript": "~3.7.2"
  },
  "scripts": {
    "start": "CI=true react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "lint": "tsc --noEmit && eslint \"**/*.{js,jsx,ts,tsx}\" --fix"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {}
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ],
  "files": [
    "src/types.d.ts"
  ]
}

测试我创建的

import axios from 'axios';
test("Check if Company Details exists", () => {
  expect(false).toBe(false);
});

我收到的问题

同样,可以清楚地看到测试套件尚未运行

我尝试了不同的方法,但到目前为止没有任何帮助。

评论