grunt mocha:PhantomJS超时,可能是由于缺少mocha run()调用
我尝试在requirejs中使用grunt mocha,但出现以下错误:grunt mocha:PhantomJS超时,可能是由于缺少mocha run()调用,phantomjs,mocha.js,Phantomjs,Mocha.js,我尝试在requirejs中使用grunt mocha,但出现以下错误: Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue. 如果我尝试使用mochajs.org上最简单的示例,它可以工作,但由于某些原因,requirejs不起作用 这是我的档案 test/browser/runner.html: <!DOCTYPE html> <
Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
如果我尝试使用mochajs.org上最简单的示例,它可以工作,但由于某些原因,requirejs不起作用
这是我的档案
test/browser/runner.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Browser test</title>
<link rel="stylesheet" media="all" href="./../../bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script data-main="runner.js" src="./../../bower_components/requirejs/require.js"></script>
</body>
</html>
define(function(require) {
describe('Component', function() {
it('test', function() {
console.log('testing...');
});
});
});
test/src/test.component.js:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Browser test</title>
<link rel="stylesheet" media="all" href="./../../bower_components/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script data-main="runner.js" src="./../../bower_components/requirejs/require.js"></script>
</body>
</html>
define(function(require) {
describe('Component', function() {
it('test', function() {
console.log('testing...');
});
});
});
grunfile.js
module.exports = function(grunt) {
grunt.initConfig({
mocha: {
options: {
reporter: 'Spec',
log: true,
run: true
},
src: ['./test/**/*.html']
}
});
grunt.loadNpmTasks('grunt-mocha');
};
输出如下:
$ grunt mocha
Running "mocha:src" (mocha) task
Testing: ./test/browser/runner.html
component success
mocha should be running
testing...
Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
Aborted due to warnings.
所以我很确定没有语法错误,它应该是有效的。我可能只是在放屁:)
任何想法都将不胜感激。
谢谢大家我也遇到了同样的问题——我用咕噜摩卡测试
插件解决了这个问题。我将grunt
文件中的任务命名更改为mochaTest
,并安装了grunt mocha test
:
npm install grunt-mocha-test --save-dev
现在它开始工作了