Skip to content

Commit

Permalink
fix: should pass env.EGG_TYPESCRIPT at test
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Mar 28, 2018
1 parent 7952f6c commit b0d093a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
5 changes: 4 additions & 1 deletion lib/cmd/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class TestCommand extends Command {

* run(context) {
const opt = {
env: Object.assign({ NODE_ENV: 'test' }, context.env),
env: Object.assign({
NODE_ENV: 'test',
EGG_TYPESCRIPT: context.argv.typescript,
}, context.env),
execArgv: context.execArgv,
};
const mochaFile = require.resolve('mocha/bin/_mocha');
Expand Down
10 changes: 1 addition & 9 deletions test/fixtures/example-ts/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
'use strict';

import { Application, Context } from 'egg';
import { default as mock, MockOption, BaseMockApplication } from 'egg-mock';
import * as path from 'path';
import { app } from 'egg-mock/bootstrap';

describe('test/index.test.ts', () => {
let app: BaseMockApplication<Application, Context>;
before(() => {
app = mock.app({ typescript: true } as MockOption);
return app.ready();
});
after(() => app.close());
it('should work', async () => {
await app
.httpRequest()
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions test/ts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('test/ts.test.js', () => {
cwd = path.join(__dirname, './fixtures/ts');
mm(process.env, 'NODE_ENV', 'development');
return coffee.fork(eggBin, [ 'dev', '--typescript' ], { cwd })
.debug()
// .debug()
.expect('stdout', /### egg from ts/)
.expect('stdout', /options.typescript=true/)
.expect('stdout', /started/)
Expand All @@ -26,7 +26,7 @@ describe('test/ts.test.js', () => {
cwd = path.join(__dirname, './fixtures/ts');
mm(process.env, 'NODE_ENV', 'development');
return coffee.fork(eggBin, [ 'test', '--typescript' ], { cwd })
.debug()
// .debug()
.notExpect('stdout', /false == true/)
.notExpect('stdout', /should not load js files/)
.expect('stdout', /--- \[string\] 'wrong assert ts'/)
Expand All @@ -41,7 +41,7 @@ describe('test/ts.test.js', () => {
}
cwd = path.join(__dirname, './fixtures/example-ts');
return coffee.fork(eggBin, [ 'dev', '--ts' ], { cwd })
.debug()
// .debug()
.expect('stdout', /hi, egg, 12345/)
.expect('stdout', /started/)
.expect('code', 0)
Expand All @@ -55,7 +55,7 @@ describe('test/ts.test.js', () => {
}
cwd = path.join(__dirname, './fixtures/example-ts');
return coffee.fork(eggBin, [ 'test', '--ts' ], { cwd })
.debug()
// .debug()
.expect('stdout', /hi, egg, 123456/)
.expect('stdout', /should work/)
.expect('code', 0)
Expand Down

0 comments on commit b0d093a

Please sign in to comment.