Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 28, 2024
1 parent 4a579ba commit 6337e20
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"dependencies": {
"@eggjs/cluster": "beta",
"@eggjs/cookies": "^3.0.0",
"@eggjs/core": "^6.2.3",
"@eggjs/core": "beta",
"@eggjs/schedule": "^5.0.2",
"@eggjs/utils": "^4.0.2",
"@eggjs/utils": "^4.1.5",
"@eggjs/watcher": "^4.0.1",
"circular-json-for-egg": "^1.0.0",
"cluster-client": "^3.7.0",
Expand Down Expand Up @@ -55,7 +55,9 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.1",
"@eggjs/bin": "^7.0.0",
"@eggjs/koa": "^2.19.1",
"@eggjs/mock": "beta",
"@eggjs/tsconfig": "1",
"@types/delegates": "^1.0.3",
"@types/koa-bodyparser": "^4.3.12",
Expand All @@ -67,8 +69,6 @@
"assert-file": "1",
"coffee": "5",
"cross-env": "7",
"@eggjs/bin": "beta",
"@eggjs/mock": "beta",
"egg-plugin-puml": "^2.4.0",
"egg-tracer": "^2.1.0",
"egg-view-nunjucks": "^2.3.0",
Expand All @@ -79,11 +79,11 @@
"mm": "^3.4.0",
"pedding": "^1.1.0",
"prettier": "^2.7.1",
"rimraf": "6",
"runscript": "^2.0.1",
"sdk-base": "^4.2.1",
"spy": "^1.0.0",
"supertest": "^7.0.0",
"rimraf": "6",
"tshy": "^3.0.2",
"tshy-after": "1",
"typescript": "5"
Expand All @@ -96,7 +96,8 @@
"test-local": "egg-bin test",
"test:changed": "egg-bin test --changed",
"preci": "npm run clean && npm run lint",
"ci": "egg-bin cov && npm run prepublishOnly",
"ci": "egg-bin cov",
"postci": "npm run prepublishOnly && npm run clean",
"prepublishOnly": "tshy && tshy-after && attw --pack",
"site:dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider APP_ROOT=./site dumi dev",
"site:devWithNode14-16": "cross-env APP_ROOT=./site dumi dev",
Expand Down
5 changes: 3 additions & 2 deletions test/app/extend/application.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ describe('test/app/extend/application.test.ts', () => {
it('should work for app.keys and app.keys=', async () => {
assert.deepEqual(app.keys, [ 'foo' ]);
// `app.keys=` will be ignored
app.keys = undefined;
assert.deepEqual(app.keys, [ 'foo' ]);
// TypeError: Cannot set property keys of #<Application> which has only a getter
// app.keys = undefined;
// assert.deepEqual(app.keys, [ 'foo' ]);
});
});
});
12 changes: 6 additions & 6 deletions test/app/extend/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('test/app/extend/context.test.ts', () => {
.get('/logger?message=foo')
.expect('logger');

await scheduler.wait(5000);
await scheduler.wait(1200);

const errorContent = fs.readFileSync(path.join(logDir, 'common-error.log'), 'utf8');
assert(errorContent.includes('nodejs.Error: error foo'));
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('test/app/extend/context.test.ts', () => {
.get('/logger?message=foo')
.expect('logger');

await scheduler.wait(5000);
await scheduler.wait(1200);

const errorContent = fs.readFileSync(path.join(logDir, 'common-error.log'), 'utf8');
assert(errorContent.includes('nodejs.Error: error foo'));
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('test/app/extend/context.test.ts', () => {
.get('/logger?message=foo')
.expect('logger');

await scheduler.wait(5000);
await scheduler.wait(2000);

const errorContent = fs.readFileSync(path.join(logDir, 'common-error.log'), 'utf8');
assert(errorContent.includes('nodejs.Error: error foo'));
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('test/app/extend/context.test.ts', () => {
.get('/')
.expect(200)
.expect('hello');
await scheduler.wait(5000);
await scheduler.wait(1200);
const logDir = app.config.logger.dir!;
const log = fs.readFileSync(path.join(logDir, 'ctx-background-web.log'), 'utf8');
assert(/background run result file size: \d+/.test(log));
Expand All @@ -343,7 +343,7 @@ describe('test/app/extend/context.test.ts', () => {
.get('/custom')
.expect(200)
.expect('hello');
await scheduler.wait(5000);
await scheduler.wait(1200);
const logDir = app.config.logger.dir!;
const log = fs.readFileSync(path.join(logDir, 'ctx-background-web.log'), 'utf8');
assert(/background run result file size: \d+/.test(log));
Expand All @@ -366,7 +366,7 @@ describe('test/app/extend/context.test.ts', () => {
.get('/error')
.expect(200)
.expect('hello error');
await scheduler.wait(5000);
await scheduler.wait(1200);
assert(errorHadEmit);
const logDir = app.config.logger.dir!;
const log = fs.readFileSync(path.join(logDir, 'common-error.log'), 'utf8');
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/apps/async-app/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module.exports = app => {
app.beforeStart(async () => {
await Promise.resolve();
await app.runSchedule('async');
app.beforeStartExecuted = true;
});

app.ready(async () => {
await app.runSchedule('async');
});

app.beforeClose(async () => {
await Promise.resolve();
app.beforeCloseExecuted = true;
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/apps/async-app/app/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = app => {
app.get('/api', app.middlewares.router(), 'api.index');
};
2 changes: 0 additions & 2 deletions test/fixtures/apps/async-app/app/schedule/async.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

exports.schedule = {
type: 'worker',
interval: 1000000,
Expand Down

0 comments on commit 6337e20

Please sign in to comment.