Skip to content

Commit 5281b14

Browse files
committed
test: disable watcher in mock apps
1 parent 521bef4 commit 5281b14

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
"scripts": {
5050
"lint": "eslint .",
5151
"test": "npm run lint -- --fix && npm run test-local",
52-
"test-local": "egg-bin test",
53-
"cov": "egg-bin cov",
52+
"test-local": "egg-bin test --require ./test/setup.js",
53+
"cov": "egg-bin cov --require ./test/setup.js",
5454
"ci": "npm run lint && npm run cov"
5555
},
5656
"repository": {

‎test/setup.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const mm = require('egg-mock');
4+
5+
const app = mm.app;
6+
const cluster = mm.cluster;
7+
8+
function disableWatcher(options) {
9+
options = options || {};
10+
return {
11+
...options,
12+
plugins: {
13+
...options.plugins,
14+
watcher: {
15+
...options.plugins?.watcher,
16+
enable: false,
17+
},
18+
},
19+
};
20+
}
21+
22+
mm.app = options => app(disableWatcher(options));
23+
mm.cluster = options => cluster(disableWatcher(options));

0 commit comments

Comments
 (0)