Skip to content

Commit

Permalink
feat: support ts
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Mar 27, 2018
1 parent e7284dd commit 8487c7b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Environment list https://github.com/eggjs/egg-core/blob/master/lib/loader/egg_lo
Mock level that print to stdout/stderr

```js
// 不输出到终端
// DON'T log to terminal
mm.consoleLevel('NONE');
```

Expand Down Expand Up @@ -265,6 +265,12 @@ Clean all logs directory, default is true.

If you are using `ava`, disable it.

#### typescript {Boolean}

Enable Typescript support, default is false.

Support read from `process.env.EGG_TYPESCRIPT`.

### app.httpRequest()

Request current app http server.
Expand Down Expand Up @@ -349,7 +355,7 @@ it('should mock user name', function* () {
app.mockService('user', 'getName', function* (ctx, methodName, args) {
return 'popomore';
});
const ctx = app.mockContext();
const ctx = app.mockContext();
yield ctx.service.user.getName();
});
```
Expand Down
8 changes: 7 additions & 1 deletion README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ mm.app({

如果是通过 ava 等并行测试框架进行测试,需要手动在执行测试前进行统一的日志清理,不能通过 mm 来处理,设置 `clean``false`

#### typescript {Boolean}

开启 TypeScript 支持,默认关闭。

支持读取环境变量 `process.env.EGG_TYPESCRIPT`

### app.httpRequest()

请求当前应用 http 服务的辅助工具。
Expand Down Expand Up @@ -361,7 +367,7 @@ it('should mock user name', function* () {
app.mockService('user', 'getName', function* (ctx, methodName, args) {
return 'popomore';
});
const ctx = app.mockContext();
const ctx = app.mockContext();
yield ctx.service.user.getName();
});
```
Expand Down
1 change: 1 addition & 0 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const mock = require('./index').default;

const options = {};
if (process.env.EGG_BASE_DIR) options.baseDir = process.env.EGG_BASE_DIR;
if (process.env.EGG_TYPESCRIPT) options.typescript = process.env.EGG_TYPESCRIPT;
const app = mock.app(options);

before(() => app.ready());
Expand Down
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export interface MockOption {
* Remove $baseDir/logs
*/
clean?: boolean;

/**
* Enable typescript support
*/
typescript: boolean;
}

type EnvType = 'default' | 'test' | 'prod' | 'local' | 'unittest';
Expand Down
1 change: 1 addition & 0 deletions lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ClusterApplication extends Coffee {
* - {String} baseDir - The directory of the application
* - {Object} plugins - Tustom you plugins
* - {String} framework - The directory of the egg framework
* - {Boolean} [typescript] - Enable TypeScript support
* - {Boolean} [cache=true] - Cache application based on baseDir
* - {Boolean} [coverage=true] - Swtich on process coverage, but it'll be slower
* - {Boolean} [clean=true] - Remove $baseDir/logs
Expand Down

0 comments on commit 8487c7b

Please sign in to comment.