Skip to content

Commit a55969f

Browse files
committed
f
1 parent 2a05a99 commit a55969f

27 files changed

+985
-611
lines changed

.oxlintrc.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,20 @@
139139
"jsdoc/require-returns": "allow",
140140
"jsdoc/require-param": "allow"
141141
},
142-
"ignorePatterns": ["index.d.ts", "test/fixtures/**", "__snapshots__", "test", "benchmark"]
142+
"overrides": [
143+
{
144+
"rules": {
145+
"unicorn/no-array-for-each": "allow",
146+
"promise/avoid-new": "allow",
147+
"max-nested-callbacks": "allow"
148+
},
149+
"files": ["test/**/*.ts"]
150+
}
151+
],
152+
"ignorePatterns": [
153+
"index.d.ts",
154+
"test/fixtures/**",
155+
"__snapshots__",
156+
"benchmark"
157+
]
143158
}

test/egg-ts.test.ts

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { strict as assert } from 'node:assert';
1+
import assert from 'node:assert/strict';
2+
23
import { mm } from 'mm';
34
import { request } from '@eggjs/supertest';
45
import coffee from 'coffee';
6+
57
import { utils } from '../src/index.js';
6-
import { Application, createApp, getFilepath } from './helper.js';
8+
import { createApp, getFilepath, type Application } from './helper.js';
79

810
describe('test/egg-ts.test.ts', () => {
911
let app: Application | undefined;
@@ -14,7 +16,9 @@ describe('test/egg-ts.test.ts', () => {
1416
});
1517

1618
afterEach(async () => {
17-
app && await app.close();
19+
if (app) {
20+
await app.close();
21+
}
1822
app = undefined;
1923
return mm.restore();
2024
// delete require.extensions['.ts'];
@@ -143,7 +147,7 @@ describe('test/egg-ts.test.ts', () => {
143147

144148
it.skip('should not load ts files while EGG_TYPESCRIPT was true but no extensions', async () => {
145149
mm(process.env, 'EGG_TYPESCRIPT', 'true');
146-
mm(utils, 'extensions', [ '.js', '.json' ]);
150+
mm(utils, 'extensions', ['.js', '.json']);
147151
app = createApp('egg-ts-js');
148152
await app.loader.loadService();
149153
assert(app.serviceClasses.lord);
@@ -152,26 +156,50 @@ describe('test/egg-ts.test.ts', () => {
152156

153157
it.skip('should compile app-ts without error', async () => {
154158
await coffee
155-
.spawn('node', [ '--require', 'ts-node/register/type-check', getFilepath('app-ts/app.ts') ], {
156-
env: Object.assign({}, process.env, {
157-
TS_NODE_PROJECT: getFilepath('app-ts/tsconfig.json'),
158-
}),
159-
})
159+
.spawn(
160+
'node',
161+
[
162+
'--require',
163+
'ts-node/register/type-check',
164+
getFilepath('app-ts/app.ts'),
165+
],
166+
{
167+
env: {
168+
...process.env,
169+
TS_NODE_PROJECT: getFilepath('app-ts/tsconfig.json'),
170+
},
171+
}
172+
)
160173
.debug()
161174
.expect('code', 0)
162175
.end();
163176
});
164177

165178
it.skip('should compile error with app-ts/error', async () => {
166179
await coffee
167-
.spawn('node', [ '--require', 'ts-node/register/type-check', getFilepath('app-ts/app-error.ts') ], {
168-
env: Object.assign({}, process.env, {
169-
TS_NODE_PROJECT: getFilepath('app-ts/tsconfig.json'),
170-
}),
171-
})
180+
.spawn(
181+
'node',
182+
[
183+
'--require',
184+
'ts-node/register/type-check',
185+
getFilepath('app-ts/app-error.ts'),
186+
],
187+
{
188+
env: {
189+
...process.env,
190+
TS_NODE_PROJECT: getFilepath('app-ts/tsconfig.json'),
191+
},
192+
}
193+
)
172194
.debug()
173-
.expect('stderr', /Property 'abb' does not exist on type 'EggCore<{ env: string; }>'/)
174-
.expect('stderr', /Property 'abc' does not exist on type 'typeof BaseContextClass'/)
195+
.expect(
196+
'stderr',
197+
/Property 'abb' does not exist on type 'EggCore<{ env: string; }>'/
198+
)
199+
.expect(
200+
'stderr',
201+
/Property 'abc' does not exist on type 'typeof BaseContextClass'/
202+
)
175203
.expect('stderr', /'loadPlugin' is protected/)
176204
.expect('stderr', /'loadConfig' is protected/)
177205
.expect('stderr', /'loadApplicationExtend' is protected/)
@@ -183,7 +211,10 @@ describe('test/egg-ts.test.ts', () => {
183211
.expect('stderr', /'loadCustomAgent' is protected/)
184212
.expect('stderr', /'loadService' is protected/)
185213
.expect('stderr', /'loadController' is protected/)
186-
.expect('stderr', /Property 'checkEnvType' does not exist on type 'string'/)
214+
.expect(
215+
'stderr',
216+
/Property 'checkEnvType' does not exist on type 'string'/
217+
)
187218
.expect('stderr', /'ctx' is protected/)
188219
.expect('code', 1)
189220
.end();

0 commit comments

Comments
 (0)