【问题标题】:Jest -UnhandledPromiseRejection TypeError Path must be a stringJest -UnhandledPromiseRejection TypeError 路径必须是字符串
【发布时间】:2017-10-12 09:43:58
【问题描述】:

在安装所有必要的依赖项(npm install/bower install)后尝试运行 jest,所有需要的包仍然在 package.json 中 - 我得到一个错误,如图所示:当我运行 jest -(我已经尝试更改版本开玩笑的)

Using Jest CLI v0.7.1
(node:9212) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Path must be a string. Received [//path of the file]

我尝试运行该应用程序:当我运行 gulp serve 时,我得到以下信息:

Unhandled promise rejection (rejection id: 3): TypeError: $.ajax is not a function

这两个错误是否相关。 请参考以下文件:

1) 我正在使用的完整源代码

https://www.dropbox.com/sh/mc3j9k4qetz7dsm/AADOgMl7AQov0BDzhDDvKdzva?dl=0

2) 错误显示方式的截屏 https://www.dropbox.com/s/v45wlizc47f8kbc/JestAjaxfunction_PromiseRejection.wmv?dl=0

感谢您的帮助, 纳文

【问题讨论】:

    标签: node.js ajax reactjs gulp jestjs


    【解决方案1】:

    在我的例子中,这个错误是在更新 jest 21 之后发生的。

    修复是在我调用 jest 时,包括 .(当前目录)。

    坏了:cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=test node --harmony_proxies node_modules/.bin/jest

    固定:cross-env BABEL_DISABLE_CACHE=1 NODE_ENV=test node --harmony_proxies node_modules/.bin/jest .

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-26
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 2017-04-23
      • 2020-08-12
      • 2017-05-18
      • 2020-10-21
      相关资源
      最近更新 更多