Gruntjs 无法使用grunt、phantomjs和mocha设置测试环境

Gruntjs 无法使用grunt、phantomjs和mocha设置测试环境,gruntjs,phantomjs,mocha.js,yeoman,Gruntjs,Phantomjs,Mocha.js,Yeoman,我正在尝试使用yeoman用grunt、phantomjs和mocha建立一个测试环境。问题是在运行测试任务时,我收到以下警告: Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue. 但是我正在index.html文件中调用mocha.run()。这是: <!doctype html> <html> <head>

我正在尝试使用yeoman用grunt、phantomjs和mocha建立一个测试环境。问题是在运行测试任务时,我收到以下警告:

Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
但是我正在index.html文件中调用
mocha.run()
。这是:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Mocha Spec Runner</title>
    <link rel="stylesheet" href="bower_components/mocha/mocha.css">
</head>
<body>
    <div id="mocha"></div>
    <script src="bower_components/mocha/mocha.js"></script>
    <script>mocha.setup('bdd')</script>
    <script src="bower_components/chai/chai.js"></script>
    <script>
        var assert = chai.assert;
        var expect = chai.expect;
        var should = chai.should();
    </script>

    <!-- include source files here... -->

    <!-- include spec files here... -->
    <script src="spec/test.js"></script>

    <script>
      mocha.run();
    </script>
</body>
</html>

摩卡规格跑步鞋
摩卡咖啡设置(“bdd”)
var assert=chai.assert;
var expect=chai.expect;
var-should=chai.should();
mocha.run();
我想我的问题出在我的Gruntfile文件里,我一定错过了什么。以下是我的一些Grunfile文件:

connect: {
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
...


mocha: {
  test: {
    src: ['test/*.html'],
    options: {
      urls: [ 'http://localhost:9001/test/index.html' ]
    }
  }
}

...

grunt.registerTask('test', [
  'clean:server',
  'concurrent:test',
  'autoprefixer',
  'connect:test',
  'mocha'   ]);
连接:{
测试:{
选项:{
港口:9001,
基数:[
“.tmp”,
"测试",,
''
]
}
},
...
摩卡咖啡:{
测试:{
src:['test/*.html'],
选项:{
网址:['http://localhost:9001/test/index.html' ]
}
}
}
...
grunt.registerTask('test'[
“清理:服务器”,
“并发:测试”,
“自动刷新器”,
'连接:测试',
"摩卡咖啡";;

尝试设置mocha.test.options.run=true

我收到了相同的错误消息,然后我意识到在yeoman设置中实际上有两个bower_组件目录

$> ls -la
...
bower_components
...
test/bower_components
当我克隆yo生成的应用程序的git repo时,它有以下.gitignore文件

node_modules
dist
.tmp
.sass-cache
bower_components
test/bower_components
所以你需要运行两次

bower install
一次在[root]和一次在[root]/test中