Skip to content

Commit

Permalink
fix: .setup.js should be the first test file (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Jan 24, 2017
1 parent 9ec223a commit 4f45c6b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ exports.formatTestArgs = args => {
newArgs.push(require.resolve('intelli-espower-loader'));
}

// auto require setup file
// auto add setup file as the first test file
const setupFile = exports.getTestSetupFile();
if (setupFile) {
newArgs.push('--require');
newArgs.push(setupFile);
}

Expand Down
3 changes: 1 addition & 2 deletions test/egg-dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ describe('egg-bin dev', () => {
it('should auto detect available port', done => {
coffee.fork(eggBin, [ 'dev' ], { cwd: appdir })
// .debug()
.expect('stdout', `{"baseDir":"${appdir}","workers":1,"port":"7002","customEgg":"${customEgg}"}\n`)
.expect('stderr', /\[egg-bin] server port 7001 is in use/)
.expect('stderr', /\[egg-bin] server port 7001 is in use, now using port \d+/)
.expect('code', 0)
.end(done);
});
Expand Down
1 change: 1 addition & 0 deletions test/egg-test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ describe('egg-bin test', () => {
cwd: path.join(__dirname, 'fixtures/enzyme-example-mocha'),
})
// .debug()
.expect('stdout', /before hook: delay 10ms/)
.expect('stdout', /3 passing/)
.expect('code', 0)
.end();
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/enzyme-example-mocha/test/.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ global.navigator = {
userAgent: 'node.js'
};

global.assert = require('assert');

documentRef = document;

before(done => {
console.log('before hook: delay 10ms');
setTimeout(done, 10);
});
1 change: 0 additions & 1 deletion test/fixtures/enzyme-example-mocha/test/Foo.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import assert from 'assert';
import { shallow, mount, render } from 'enzyme';
import Foo from '../src/Foo';

Expand Down

0 comments on commit 4f45c6b

Please sign in to comment.