开玩笑TypeError:路径必须是字符串.收到未定义 [英] Jest TypeError: Path must be a string. Received undefined

查看:353
本文介绍了开玩笑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:

测试套件无法运行

Test suite failed to run

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卸载-g开玩笑
  • npm install -g jest
  • npm缓存清理
  • npm安装

这篇关于开玩笑TypeError:路径必须是字符串.收到未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆