diff --git a/lib/cmd/test.js b/lib/cmd/test.js index 076c00b3..d601ee56 100644 --- a/lib/cmd/test.js +++ b/lib/cmd/test.js @@ -59,6 +59,8 @@ class TestCommand extends Command { /* istanbul ignore next */ testArgv.timeout = testArgv.timeout || process.env.TEST_TIMEOUT || 60000; testArgv.reporter = testArgv.reporter || process.env.TEST_REPORTER; + // force exit + testArgv.exit = true; if (debug) { // --no-timeouts diff --git a/test/fixtures/no-exit/test/foo.test.js b/test/fixtures/no-exit/test/foo.test.js new file mode 100644 index 00000000..d9615257 --- /dev/null +++ b/test/fixtures/no-exit/test/foo.test.js @@ -0,0 +1,16 @@ +'use strict'; + +const http = require('http'); +const assert = require('assert'); + +describe('mocha-test', () => { + it('should work', () => { + assert(true); + }); +}); + +const server = http.createServer((req, res) => { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('okay'); +}); +server.listen(); diff --git a/test/lib/cmd/test.test.js b/test/lib/cmd/test.test.js index e5d71d94..1ccb351f 100644 --- a/test/lib/cmd/test.test.js +++ b/test/lib/cmd/test.test.js @@ -110,6 +110,14 @@ describe('test/lib/cmd/test.test.js', () => { .end(); }); + it('should force exit', () => { + const cwd = path.join(__dirname, '../../fixtures/no-exit'); + return coffee.fork(eggBin, [ 'test' ], { cwd }) + .debug() + .expect('code', 0) + .end(); + }); + describe('simplify mocha error stack', () => { const cwd = path.join(__dirname, '../../fixtures/test-files-stack');