【发布时间】:2014-07-18 11:04:50
【问题描述】:
我在运行 grunt 的 mocha 测试时不断收到此消息。
Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
测试在浏览器中运行良好,但无法从 grunt 启动。我一直在使用this Grunt 插件来运行我的浏览器测试,我的这是我的 Gruntfile.js 的相关部分。
// I've checked if it does server while my tests are running & it does
connect: {
test: {
// public is where all my files are, of course
base: 'public',
port: 8080
}
},
mocha: {
client: {
urls: ['http://0.0.0.0:8080/test.html'],
log: true,
}
},
这是test.html 文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link rel="stylesheet" href="css/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="js/test.js"></script>
<script>mocha.run();</script>
</body>
</html>
这是public 目录
/public
- index.html
- test.html
/css
- main.css
- mocha.css
/js
- main.js
- test.js \\ contains main.js + mocha.js + my tests
这是 grunt 在失败后的输出。
Running "uglify:dev" (uglify) task
File public/js/main.js created.
File public/js/test.js created.
Running "connect:test" (connect) task
Started connect web server on http://0.0.0.0:8080
Running "mocha:client" (mocha) task
Testing: http://0.0.0.0:8080/test.html
Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
Aborted due to warnings.
测试所需的所有 src 都放在一个文件中,其中包括我的源代码(及其依赖项)、mocha 和测试。
【问题讨论】:
标签: javascript gruntjs phantomjs mocha.js