diff --git a/package.json b/package.json index aacce56..142230f 100644 --- a/package.json +++ b/package.json @@ -45,12 +45,15 @@ "grunt": "^0.4.5", "grunt-contrib-uglify": "^0.6.0", "mocha": "^2.2.5", + "mocha-phantomjs": "^3.5.4", "open": "0.0.5", + "phantomjs": "1.9.1 - 1.9.7-15", "serve-static": "^1.7.1" }, "scripts": { "test-browser": "node tests/test.js", + "test-phantomjs": "node tests/test.js --phantomjs", "test-node": "mocha tests/node-tests.js", - "test": "npm run test-node && npm run test-browser" + "test": "npm run test-node && npm run test-phantomjs" } } diff --git a/tests/test.js b/tests/test.js index 4961d4f..4c07bb8 100644 --- a/tests/test.js +++ b/tests/test.js @@ -2,8 +2,18 @@ var connect = require('connect'); var serveStatic = require('serve-static'); var open = require('open'); var path = require('path'); +var child_process = require('child_process'); -connect().use(serveStatic(path.join(__dirname, '/..'))).listen(8071, function() { - open('http://localhost:8071/tests/tests.html'); - console.log('Serving tests...'); +var server = connect().use(serveStatic(path.join(__dirname, '/..'))).listen(8071, function() { + if (process.argv.indexOf('--phantomjs') !== -1) { + child_process.spawn('node_modules/.bin/mocha-phantomjs', ['http://localhost:8071/tests/tests.html'], { + stdio: 'inherit' + }).on('exit', function () { + server.close(); + }); + + } else { + open('http://localhost:8071/tests/tests.html'); + console.log('Serving tests...'); + } }); diff --git a/tests/tests.html b/tests/tests.html index 049ef26..6cfd994 100644 --- a/tests/tests.html +++ b/tests/tests.html @@ -17,9 +17,14 @@