8000 test: add missing deps for unittest by fengmk2 · Pull Request #5110 · eggjs/egg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: add missing deps for unittest #5110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ test/fixtures/apps/app-ts/**/*.js
!test/fixtures/apps/app-ts/node_modules/**/*.js
test/fixtures/apps/app-ts-esm/**/*.js
test/fixtures/apps/app-ts-type-check/**/*.js
test/fixtures/apps/app-ts-type-check/**/*.d.ts
test/fixtures/apps/app-ts/**/*.d.ts
test/fixtures/apps/app-ts-esm/**/*.d.ts

# site
site/dist
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
"ylru": "^1.3.2"
},
"devDependencies": {
"@eggjs/tsconfig": "^1.1.0",
"@types/node": "^18.11.18",
"@umijs/preset-react": "^2.1.6",
"address": "^1.2.1",
"antd": "^4.23.2",
Expand All @@ -82,6 +84,7 @@
"pedding": "^1.1.0",
"prettier": "^2.7.1",
"runscript": "^1.5.3",
"sdk-base": "^4.2.1",
"spy": "^1.0.0",
"supertest": "^6.2.4",
"ts-node": "^10.9.1",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/apps/app-ts-esm/app/controller/foo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, RequestObjectBody } from 'egg';
import { Controller } from 'egg';

// add user controller and service
declare module 'egg' {
Expand Down
12 changes: 9 additions & 3 deletions test/fixtures/apps/app-ts-type-check/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"extends": "../app-ts/tsconfig.json",
"extends": "@eggjs/tsconfig",
"compilerOptions": {
"baseUrl": "."
"baseUrl": ".",
"paths": {
"egg": [
"../../../../index"
]
},
"esModuleInterop": false
},
"exclude": [
"./error.ts"
]
}
}
2 changes: 1 addition & 1 deletion test/fixtures/apps/app-ts-type-check/yadan.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ declare module 'yadan' {
}
}

export = Egg;
export = Egg;
3 changes: 3 additions & 0 deletions test/fixtures/apps/app-ts/app/controller/foo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default class FooController extends Controller {
result = await this.app.httpclient.request('url', request);
result = await this.ctx.httpclient.curl('url', request);
result = await this.ctx.httpclient.request('url', request);
console.log(result);
}

async requestWithHttpclient(request: RequestOptions) {
Expand All @@ -68,6 +69,7 @@ export default class FooController extends Controller {
result = await this.app.httpclient.request('url', request);
result = await this.ctx.httpclient.curl('url', request);
result = await this.ctx.httpclient.request('url', request);
console.log(result);
}

async requestWithHttpclient2(request: RequestOptions2) {
Expand All @@ -77,6 +79,7 @@ export default class FooController extends Controller {
result = await this.app.httpclient.request('url', request);
result = await this.ctx.httpclient.curl('url', request);
result = await this.ctx.httpclient.request('url', request);
console.log(result);
}

async httpclient() {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/apps/app-ts/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export default (app: Application) => {
ctx.getLogger('logger').info('test');

const level: LoggerLevel = 'DEBUG';
console.log(level);
};
8 changes: 2 additions & 6 deletions test/fixtures/apps/app-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"extends": "@eggjs/tsconfig",
"compilerOptions": {
"target": "es2017",
"baseUrl": ".",
"paths": {
"egg": [
"../../../../index"
]
},
"types" : ["node"],
"module": "commonjs",
"strict": true,
"noImplicitAny": false
}
}
}
6 changes: 3 additions & 3 deletions test/fixtures/apps/tracer-demo/tracer.js
AE8F
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict';

const { performance } = require('perf_hooks');
const uuid = require('uuid');
const { randomUUID } = require('crypto');

module.exports = app => {
app.httpclient.on('request', req => {
if (!req.ctx) {
// auto set anonymous context
req.ctx = req.args.ctx = app.createAnonymousContext();
req.ctx.traceId = 'anonymous-' + uuid.v1();
req.ctx.traceId = 'anonymous-' + randomUUID();
}
// set tracer id
if (!req.ctx.traceId) {
req.ctx.traceId = uuid.v1();
req.ctx.traceId = randomUUID();
}
req.starttime = performance.now();
req.args.headers = req.args.headers || {};
Expand Down
5 changes: 1 addition & 4 deletions test/lib/core/httpclient_tracer_demo.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const assert = require('assert');
const utils = require('../../utils');

Expand Down Expand Up @@ -47,8 +45,7 @@ describe('test/lib/core/httpclient_tracer_demo.test.js', () => {
assert(res.body.data['x-request-id'].startsWith('anonymous-'));
})
.expect(200);
// wait for windows log store
if (process.platform === 'win32') await utils.sleep(2000);
await utils.sleep(2000);
app.expectLog(/ INFO \d+ \[-\/127.0.0.1\/mock-traceId-123123\/\d+ms GET \/foo\?url=http%3A%2F%2F127.0.0.1%3A\d+%2Fget_headers] app logger support traceId/);
});
});
0