From d6f76de349ae76d9e7a0deaedbd0fef57bfdd991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 22 Dec 2014 22:08:24 +0100 Subject: [PATCH] Repair grunt express task --- Gruntfile.js | 8 ++++++++ bin/server.js | 20 +++++++++++--------- test/api/apiTest.js | 14 -------------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1f0ad14..f18a304 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -115,6 +115,13 @@ module.exports = function(grunt) { showStack: true } }, + test: { + options: { + port: 8387, + server: './coverage/bin/server.js', + showStack: true + } + }, testSuite: { options: { port: 8388, @@ -184,6 +191,7 @@ module.exports = function(grunt) { 'copy-test-server-settings', 'blanket', 'copy:coverage', + 'express:test', 'mochaTest:test', 'mochaTest:coverage' ]); diff --git a/bin/server.js b/bin/server.js index ea6ca38..5263db7 100644 --- a/bin/server.js +++ b/bin/server.js @@ -20,14 +20,16 @@ var frontController = require('../lib/server/controllers/frontController // Let's start the server! -var settings = require('../server_config/settings.json'); -server.listen(settings.serverPort, function() { - console.log('Listening on port %d', server.address().port); +if (!process.env.GRUNTED) { + var settings = require('../server_config/settings.json'); + server.listen(settings.serverPort, function() { + console.log('Listening on port %d', server.address().port); - // For the tests - if (server.startTests) { - server.startTests(); - } -}); + // For the tests + if (server.startTests) { + server.startTests(); + } + }); +} -module.exports = server; \ No newline at end of file +module.exports = app; \ No newline at end of file diff --git a/test/api/apiTest.js b/test/api/apiTest.js index f7ff020..d4695e6 100644 --- a/test/api/apiTest.js +++ b/test/api/apiTest.js @@ -16,14 +16,6 @@ describe('api', function() { var syncRunResultUrl; var asyncRunId; - var apiServer; - - - // Start the server - before(function(done) { - apiServer = require('../../bin/server.js'); - apiServer.startTests = done; - }); it('should refuse a query with an invalid key', function(done) { @@ -451,10 +443,4 @@ describe('api', function() { }); }); - - // Stop the server - after(function() { - console.log('Closing the server'); - apiServer.close(); - }); });