jest 报错 Could not find a config file based on provided values

待我称王封你为后i 2023-02-18 10:52 90阅读 0赞
  1. Error: Could not find a config file based on provided values:
  2. path: "/Users/mo/Documents/Demo/node"
  3. cwd: "/Users/mo/Documents/Demo/node"
  4. Config paths must be specified by either a direct path to a config
  5. file, or a path to a directory. If directory is given, Jest will try to
  6. traverse directory tree up, until it finds one of those files in exact order: "jest.config.js" or "jest.config.mjs" or "jest.config.cjs" or "jest.config.json".
  7. at resolveConfigPathByTraversing (/Users/mo/node_modules/jest-config/build/resolveConfigPath.js:135:11)
  8. at resolveConfigPathByTraversing (/Users/mo/node_modules/jest-config/build/resolveConfigPath.js:138:10)
  9. at resolveConfigPathByTraversing (/Users/mo/node_modules/jest-config/build/resolveConfigPath.js:138:10)
  10. at resolveConfigPathByTraversing (/Users/mo/node_modules/jest-config/build/resolveConfigPath.js:138:10)
  11. at resolveConfigPathByTraversing (/Users/mo/node_modules/jest-config/build/resolveConfigPath.js:138:10)
  12. at resolveConfigPathByTraversing (/Users/mo/node_modules/jest-config/build/resolveConfigPath.js:138:10)
  13. at _default (/Users/mo/node_modules/jest-config/build/resolveConfigPath.js:113:10)
  14. at readConfig (/Users/mo/node_modules/jest-config/build/index.js:213:49)
  15. at readConfigs (/Users/mo/node_modules/jest-config/build/index.js:400:32)
  16. at runCLI (/Users/mo/node_modules/@jest/core/build/cli/index.js:199:29)

解决方法

在项目目录下执行

  1. npm init

然后就可以了

发表评论

表情:
评论列表 (有 0 条评论,90人围观)

还没有评论,来说两句吧...

相关阅读