新手运行jest报错,报错信息如下:
path: “E:\webprojects_learning\web-full-stack\node\node_preview\node”
cwd: “E:\webprojects_learning\web-full-stack\node\node_preview\node”
Config paths must be specified by either a direct path to a config
file, or a path to a directory. If directory is given, Jest will try to
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”.
at resolveConfigPathByTraversing (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\resolveConfigPath.js:135:11)
at resolveConfigPathByTraversing (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\resolveConfigPath.js:138:10)
at resolveConfigPathByTraversing (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\resolveConfigPath.js:138:10)
at resolveConfigPathByTraversing (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\resolveConfigPath.js:138:10)
at resolveConfigPathByTraversing (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\resolveConfigPath.js:138:10)
at resolveConfigPathByTraversing (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\resolveConfigPath.js:138:10)
at _default (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\resolveConfigPath.js:113:10)
at readConfig (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\index.js:213:49)
at readConfigs (D:\install\nodejs\node_global\node_modules\jest\node_modules\jest-config\build\index.js:400:32)
at runCLI (D:\install\nodejs\node_global\node_modules\jest\node_modules@jest\core\build\cli\index.js:199:29)
原因是没有初始化node环境,需要先运行npm init