Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: force exit when runner complete #83

Merged
merged 3 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/cmd/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/no-exit/test/foo.test.js
Original file line number Diff line number Diff line change
@@ -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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要放到 it 里面吧?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没关系,只要能不退出就可以

Copy link
Member

@atian25 atian25 Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写到 describe 里面的 before 好点吧,mocha 的非 it 内容,好像会影响到 only / skip 这些的,因为加载的时候就执行了,会影响到其他用例。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是测试的 fixtures

res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('okay');
});
server.listen();
8 changes: 8 additions & 0 deletions test/lib/cmd/test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down