Jest TypeError:路径必须是字符串.收到未定义 [英] Jest TypeError: Path must be a string. Received undefined
本文介绍了Jest TypeError:路径必须是字符串.收到未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的 package.json 的设置
Below settings for my package.json
如果我从命令行运行 npm test
所有开玩笑的测试用例都会正确执行.如果我从命令行直接使用命令 jest
,我会收到此错误:
If I run from command line npm test
all jest test cases are executed properly.
In case I use directly the command jest
from command line I receive this error:
测试套件运行失败
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.relative (path.js:538:5)
这发生在任何测试文件上.
This happens on any test files.
知道什么地方出了问题以及如何解决吗?
Any idea what could be wrong and how to fix it?
"scripts": {
"test": "standard && jest",
"format": "standard --fix",
"start": "webpack-dev-server --config webpack.config.dev.js",
"build": "webpack --config webpack.config.prod.js"
},
推荐答案
我使用以下方法解决了这个问题:
I solved this issue using:
- npm uninstall -g jest
- npm install -g jest
- npm 缓存清理
- npm 安装
这篇关于Jest TypeError:路径必须是字符串.收到未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文