Skip to content

Commit 7e3edc6

Browse files
committed
change mockCtxStorage default to false
1 parent 561e4db commit 7e3edc6

File tree

9 files changed

+12
-6
lines changed

9 files changed

+12
-6
lines changed

example/helloworld-typescript/app/middleware/hello.ts

+3
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ export const hello: MiddlewareFunc = async (ctx, next) => {
66
console.log(ctx.performanceStarttime);
77
const res = await ctx.curl('https://eggjs.org');
88
console.log(res.status);
9+
10+
// egg watcher
11+
// console.log('egg watcher', ctx.app.watcher);
912
await next();
1013
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@eggjs/core": "^6.2.3",
2525
"@eggjs/schedule": "^5.0.2",
2626
"@eggjs/utils": "^4.0.2",
27-
"@eggjs/watcher": "^4.0.0",
27+
"@eggjs/watcher": "^4.0.1",
2828
"circular-json-for-egg": "^1.0.0",
2929
"cluster-client": "^3.7.0",
3030
"delegates": "^1.0.0",

src/app/middleware/site_file.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface SiteFileMiddlewareOptions {
1313

1414
const BUFFER_CACHE = Symbol('siteFile URL buffer cache');
1515

16-
module.exports = (options: SiteFileMiddlewareOptions) => {
16+
export default (options: SiteFileMiddlewareOptions) => {
1717
return async function siteFile(ctx: ContextDelegation, next: Next) {
1818
if (ctx.method !== 'HEAD' && ctx.method !== 'GET') {
1919
return next();

src/lib/type.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import type { MetaMiddlewareOptions } from '../app/middleware/meta.js';
1515
import type { NotFoundMiddlewareOptions } from '../app/middleware/notfound.js';
1616
import type { SiteFileMiddlewareOptions } from '../app/middleware/site_file.js';
1717

18+
// import @eggjs/watcher types
19+
// import '@eggjs/watcher';
20+
1821
type IgnoreItem = string | RegExp | ((ctx: ContextDelegation) => boolean);
1922
type IgnoreOrMatch = IgnoreItem | IgnoreItem[];
2023

test/app/extend/context.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('test/app/extend/context.test.ts', () => {
6363
const errorContent = fs.readFileSync(path.join(logDir, 'common-error.log'), 'utf8');
6464
assert(errorContent.includes('nodejs.Error: error foo'));
6565
assert(errorContent.includes('nodejs.Error: core error foo'));
66-
assert(/\[123123\/[\d.]+\/-\/\d+ms GET \/logger\?message=foo]/.test(errorContent));
66+
assert.match(errorContent, /\[123123\/[\d\.]+\/-\/[\d\.]+ms GET \/logger\?message=foo]/);
6767

6868
const loggerContent = fs.readFileSync(path.join(logDir, 'demo-web.log'), 'utf8');
6969
assert(!loggerContent.includes('debug foo'));

test/fixtures/apps/demo/app/controller/logger.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
module.exports = async function() {
42
const message = this.query.message;
53

test/lib/core/logger.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ describe('test/lib/core/logger.test.js', () => {
236236
enableFastContextLogger: true,
237237
});
238238
await utils.sleep(1000);
239-
app.expectLog(/ INFO \d+ \[-\/127\.0\.0\.1\/mock-trace-id-123\/\d+ms GET \/] enableFastContextLogger: true/);
239+
app.expectLog(/ INFO \d+ \[-\/127\.0\.0\.1\/mock-trace-id-123\/[\d\.]+ms GET \/] enableFastContextLogger: true/);
240240
});
241241

242242
describe('logger.level = DEBUG', () => {

test/utils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ function formatOptions(name: string | MockOption, options?: MockOption) {
145145
baseDir,
146146
framework: eggPath,
147147
cache: false,
148+
// change default mockCtxStorage to false because we don't need it in framework test
149+
mockCtxStorage: false,
148150
...options,
149151
};
150152
}

0 commit comments

Comments
 (0)