mocha init timeout with mocha-phantomjs

不羁岁月 提交于 2019-12-03 11:38:44

I was getting the same Failed to start mocha error when running mocha-phantomjs through the grunt-mocha-phantomjs npm package. Found the solution here.

Repeated here for reference:

To run with mocha-phantomjs, change

mocha.run();

to

if (mochaPhantomJS) {
  mochaPhantomJS.run();
}
else {
  mocha.run();
}

This file shows how to use it.

And for me, NodeJS 0.10.x does not seem to work with it. After switching to NodeJS 0.8.8, everything works as expected.

Using the current versions of mocha-phantomjs and PhantomJS now everything works fine.

Thanks for this info, I tried the above but it failed in browser saying "mochaPhantomJS is undefined". A quick tweak as per below and it works well:

if(typeof(mochaPhantomJS)!=="undefined")
{
  mochaPhantomJS.run();
}
else
{
  mocha.run();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!