diff --git a/lib/helper.js b/lib/helper.js index cabfe599..965e1e55 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -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); } diff --git a/test/egg-dev.test.js b/test/egg-dev.test.js index 6e1e1a4f..e2084cea 100644 --- a/test/egg-dev.test.js +++ b/test/egg-dev.test.js @@ -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); }); diff --git a/test/egg-test.test.js b/test/egg-test.test.js index 868dea41..9560b778 100644 --- a/test/egg-test.test.js +++ b/test/egg-test.test.js @@ -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(); diff --git a/test/fixtures/enzyme-example-mocha/test/.setup.js b/test/fixtures/enzyme-example-mocha/test/.setup.js index 718f402a..4fd044b5 100644 --- a/test/fixtures/enzyme-example-mocha/test/.setup.js +++ b/test/fixtures/enzyme-example-mocha/test/.setup.js @@ -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); +}); diff --git a/test/fixtures/enzyme-example-mocha/test/Foo.test.js b/test/fixtures/enzyme-example-mocha/test/Foo.test.js index cef63b45..27e7b056 100644 --- a/test/fixtures/enzyme-example-mocha/test/Foo.test.js +++ b/test/fixtures/enzyme-example-mocha/test/Foo.test.js @@ -1,5 +1,4 @@ import React from 'react'; -import assert from 'assert'; import { shallow, mount, render } from 'enzyme'; import Foo from '../src/Foo';