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' ]);