Ber*_*rdo 4 mocha.js phantomjs gruntjs yeoman
我正在尝试使用自耕农设置grunt,phantomjs和mocha的测试环境.问题是当运行测试任务时我得到以下警告:
Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
Run Code Online (Sandbox Code Playgroud)
但我mocha.run()在我的index.html文件中调用.这里是:
<!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>
Run Code Online (Sandbox Code Playgroud)
我认为我的问题在我的Gruntfile中,我一定是在遗漏一些东西.这是我的一些Gruntfile:
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' ]);
Run Code Online (Sandbox Code Playgroud)
我有相同的错误消息,然后我意识到在yeoman设置中实际上有两个bower_components目录.
$> ls -la
...
bower_components
...
test/bower_components
Run Code Online (Sandbox Code Playgroud)
当我克隆了一个你生成的应用程序的git repo时,它有以下.gitignore文件
node_modules
dist
.tmp
.sass-cache
bower_components
test/bower_components
Run Code Online (Sandbox Code Playgroud)
所以你需要运行两次......
bower install
Run Code Online (Sandbox Code Playgroud)
一旦进入[root]并进入[root]/test
| 归档时间: |
|
| 查看次数: |
2139 次 |
| 最近记录: |