Fix phantom mocha tests

This commit is contained in:
Tankred Hase 2014-10-09 17:31:01 +02:00 committed by Felix Hammerl
parent 84d5bd8124
commit c6fb31fd49
4 changed files with 17 additions and 14 deletions

View File

@ -32,19 +32,13 @@ module.exports = function(grunt) {
} }
}, },
mocha: { mocha_phantomjs: {
all: { all: {
options: { options: {
urls: [ urls: [
'http://localhost:<%= connect.test.options.port %>/test/unit/index.html', 'http://localhost:<%= connect.test.options.port %>/test/unit/index.html',
'http://localhost:<%= connect.test.options.port %>/test/integration/index.html' 'http://localhost:<%= connect.test.options.port %>/test/integration/index.html'
], ]
run: false,
reporter: 'Spec',
log: false,
// phanotmjs is soooo slow
timeout: 100000
} }
} }
}, },
@ -367,7 +361,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-csso'); grunt.loadNpmTasks('grunt-csso');
grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-sass');
@ -376,6 +369,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress'); grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-manifest'); grunt.loadNpmTasks('grunt-manifest');
grunt.loadNpmTasks('grunt-mocha-phantomjs');
// Build tasks // Build tasks
grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']); grunt.registerTask('dist-css', ['sass', 'autoprefixer', 'csso']);
@ -385,7 +379,7 @@ module.exports = function(grunt) {
// Test/Dev tasks // Test/Dev tasks
grunt.registerTask('dev', ['connect:dev']); grunt.registerTask('dev', ['connect:dev']);
grunt.registerTask('test', ['jshint', 'connect:test', 'mocha']); grunt.registerTask('test', ['jshint', 'connect:test', 'mocha_phantomjs']);
grunt.registerTask('prod', ['connect:prod']); grunt.registerTask('prod', ['connect:prod']);
// //

View File

@ -63,8 +63,8 @@
"grunt-contrib-watch": "~0.5.3", "grunt-contrib-watch": "~0.5.3",
"grunt-csso": "~0.6.1", "grunt-csso": "~0.6.1",
"grunt-manifest": "^0.4.0", "grunt-manifest": "^0.4.0",
"grunt-mocha": "~0.4.1", "grunt-mocha-phantomjs": "^0.6.0",
"mocha": "~1.13.0", "mocha": "^1.21.4",
"sinon": "~1.7.3", "sinon": "~1.7.3",
"time-grunt": "^1.0.0" "time-grunt": "^1.0.0"
} }

View File

@ -23,7 +23,11 @@
<script src="index.js"></script> <script src="index.js"></script>
<script> <script>
mocha.run(); if (window.mochaPhantomJS) {
mochaPhantomJS.run();
} else {
mocha.run();
}
</script> </script>
</body> </body>
</html> </html>

View File

@ -25,7 +25,12 @@
<script> <script>
mocha.checkLeaks(); mocha.checkLeaks();
mocha.globals(['chrome']); mocha.globals(['chrome']);
mocha.run();
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
} else {
mocha.run();
}
</script> </script>
</body> </body>
</html> </html>