The test itself starts the server in a before hook

This commit is contained in:
Gaël Métais
2014-12-13 13:56:21 +01:00
parent 3ad6cdef51
commit 8abfe93df7
4 changed files with 24 additions and 23 deletions
+3 -11
View File
@@ -108,12 +108,6 @@ module.exports = function(grunt) {
showStack: true
}
},
testServer: {
options: {
port: 8387,
server: './coverage/bin/server.js'
}
},
testSuite: {
options: {
port: 8388,
@@ -148,7 +142,7 @@ module.exports = function(grunt) {
var outputFile = './coverage/server_config/settings.json';
grunt.file.write(outputFile, JSON.stringify(testSettings, null, 4));
grunt.verbose.ok('File ' + outputFile + ' created');
grunt.log.ok('File ' + outputFile + ' created');
});
@@ -177,10 +171,9 @@ module.exports = function(grunt) {
grunt.registerTask('test', [
'build',
'jshint',
'copy-test-server-settings',
'express:testServer',
'express:testSuite',
'clean:coverage',
'copy-test-server-settings',
'blanket',
'copy:coverage',
'mochaTest:test',
@@ -190,10 +183,9 @@ module.exports = function(grunt) {
grunt.registerTask('test-current-work', [
'build',
'jshint',
'copy-test-server-settings',
'express:testServer',
'express:testSuite',
'clean:coverage',
'copy-test-server-settings',
'blanket',
'copy:coverage',
'mochaTest:test-current-work'
+10 -9
View File
@@ -20,13 +20,14 @@ var uiController = require('../lib/server/controllers/uiController')(
// Let's start the server!
if (!process.env.GRUNTED) {
// The server is not launched by Grunt
var settings = require('../server_config/settings.json');
server.listen(settings.serverPort, function() {
console.log('Listening on port %d', server.address().port);
});
}
var settings = require('../server_config/settings.json');
server.listen(settings.serverPort, function() {
console.log('Listening on port %d', server.address().port);
// For Grunt
module.exports = app;
// For the tests
if (server.startTests) {
server.startTests();
}
});
module.exports = server;
+10 -2
View File
@@ -14,7 +14,12 @@ var wwwUrl = 'http://localhost:8388';
describe('api', function() {
var runId;
var apiServer;
before(function(done) {
apiServer = require('../../bin/server.js');
apiServer.startTests = done;
});
it('should refuse a query with an invalid key', function(done) {
this.timeout(5000);
@@ -67,7 +72,7 @@ describe('api', function() {
});
it('should accept up to 10 anonymous runs to the API', function(done) {
this.timeout(15000);
this.timeout(5000);
function launchRun() {
var deferred = Q.defer();
@@ -126,5 +131,8 @@ describe('api', function() {
});
after(function() {
console.log('Closing the server');
apiServer.close();
});
});
+1 -1
View File
@@ -1,5 +1,5 @@
{
"serverPort": "auto",
"serverPort": "8387",
"googleAnalyticsId": "",
"authorizedKeys": {