瀏覽代碼

Repair grunt express task

Gaël Métais 10 年之前
父節點
當前提交
d6f76de349
共有 3 個文件被更改,包括 21 次插入25 次删除
  1. 8 0
      Gruntfile.js
  2. 13 11
      bin/server.js
  3. 0 14
      test/api/apiTest.js

+ 8 - 0
Gruntfile.js

@@ -115,6 +115,13 @@ module.exports = function(grunt) {
                     showStack: true
                     showStack: true
                 }
                 }
             },
             },
+            test: {
+                options: {
+                    port: 8387,
+                    server: './coverage/bin/server.js',
+                    showStack: true
+                }
+            },
             testSuite: {
             testSuite: {
                 options: {
                 options: {
                     port: 8388,
                     port: 8388,
@@ -184,6 +191,7 @@ module.exports = function(grunt) {
         'copy-test-server-settings',
         'copy-test-server-settings',
         'blanket',
         'blanket',
         'copy:coverage',
         'copy:coverage',
+        'express:test',
         'mochaTest:test',
         'mochaTest:test',
         'mochaTest:coverage'
         'mochaTest:coverage'
     ]);
     ]);

+ 13 - 11
bin/server.js

@@ -20,14 +20,16 @@ var frontController         = require('../lib/server/controllers/frontController
 
 
 
 
 // Let's start the server!
 // 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);
-
-    // For the tests
-    if (server.startTests) {
-        server.startTests();
-    }
-});
-
-module.exports = server;
+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();
+        }
+    });
+}
+
+module.exports = app;

+ 0 - 14
test/api/apiTest.js

@@ -16,14 +16,6 @@ describe('api', function() {
 
 
     var syncRunResultUrl;
     var syncRunResultUrl;
     var asyncRunId;
     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) {
     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();
-    });
 });
 });