I'm trying to setup a test environment with grunt, phantomjs and mocha using yeoman. The problem is when run the test task I got the following warning:
Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.
But I'm calling mocha.run()
in my index.html file. Here it is:
<!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>
I think my problem is inside my Gruntfile, I must be missing something. Here's some of my 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' ]);
I had the same error message and then I realised there are actually two bower_components directories in a yeoman setup.
$> ls -la
...
bower_components
...
test/bower_components
When I cloned a git repo of a yo generated app it has the following .gitignore file
node_modules
dist
.tmp
.sass-cache
bower_components
test/bower_components
So you need to run this twice...
bower install
Once in [root] and once in [root]/test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With