在我的测试中未能 运行 phantomjs

failed to run phantomjs in my tests

我按照https://github.com/vuejs-templates/webpack安装了我的项目,现在我想测试一下。

当我 运行 cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run 无法 运行 时,我看到了这些错误:

PhantomJS have not captured in 60000 ms, killing.
Trying to start PhantomJS again (1/2).
PhantomJS have not captured in 60000 ms, killing.
Trying to start PhantomJS again (2/2).
PhantomJS have not captured in 60000 ms, killing.
PhantomJS failed 2 times (timeout). Giving up.

知道我已将此行添加到我的 ~/.bashrc

export PATH="$HOME/path/to/project/node_modules/.bin:$PATH"

在我的终端中:

 --> phantomjs -v
 2.1.1

Karma 默认在 localhost 上侦听,如果无法解决,将会失败且不会出现有意义的错误。在某些时候,您可能已经从 /etc/hosts 中删除了 127.0.0.1 localhost - 尝试重新添加它,它应该会有所帮助。

归功于 zewish