Skip to content

Commit 1adfde3

Browse files
committed
feat: OTLP package updates and get latest service module
BREAKING CHANGE: keeping in sync with service module version change
1 parent e312561 commit 1adfde3

File tree

5 files changed

+3339
-2211
lines changed

5 files changed

+3339
-2211
lines changed

__tests__/index.spec.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ describe('Start and stop shared app', () => {
3333
rootDirectory: __dirname,
3434
codepath: 'src',
3535
name: 'fake-serv',
36+
version: '0.0.0',
3637
};
3738

39+
test('Should load app with defaults', async () => {
40+
await getReusableApp({
41+
rootDirectory: __dirname,
42+
});
43+
});
44+
3845
test('Start reusable app', async () => {
3946
const app = await getReusableApp(options);
4047
expect(app).toBeTruthy();
@@ -57,8 +64,6 @@ describe('Start and stop shared app', () => {
5764
await request(app).get('/foobar').expect(404);
5865
await request(app).post('/').expect(500);
5966
vi.spyOn(app.locals.services.fakeServ, 'get_something').mockResolvedValue({
60-
responseType: 'response',
61-
status: 200,
6267
body: { things: ['a', 'b', 'c'] },
6368
});
6469
const { body } = await request(app).post('/').expect(200);
@@ -71,7 +76,7 @@ describe('Start and stop shared app', () => {
7176
await clearReusableApp();
7277
expect(flags.started).toEqual(1);
7378
expect(flags.stopped).toEqual(1);
74-
expect(Promise.resolve().then(getExistingApp)).rejects.toThrow('requires a running app');
79+
await expect(Promise.resolve().then(getExistingApp)).rejects.toThrow('requires a running app');
7580
const app = await getReusableApp(options);
7681
expect(flags.started).toEqual(2);
7782
expect(flags.stopped).toEqual(1);
@@ -80,10 +85,4 @@ describe('Start and stop shared app', () => {
8085
expect(flags.started).toEqual(2);
8186
expect(flags.stopped).toEqual(2);
8287
});
83-
84-
test('Should load app with defaults', async () => {
85-
await getReusableApp({
86-
rootDirectory: __dirname,
87-
});
88-
});
8988
});

__tests__/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ServiceLocals } from '@openapi-typescript-infra/service';
33
export interface FakeServLocals extends ServiceLocals {
44
services: {
55
fakeServ: {
6-
get_something(): Promise<{ things: string[] }>;
6+
get_something(): Promise<{ body: { things: string[] } }>;
77
}
88
}
99
}

package.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,35 @@
5151
]
5252
},
5353
"devDependencies": {
54-
"@commitlint/cli": "^19.5.0",
55-
"@commitlint/config-conventional": "^19.5.0",
56-
"@openapi-typescript-infra/coconfig": "^4.6.0",
57-
"@openapi-typescript-infra/service": "^5.3.1",
54+
"@commitlint/cli": "^20.1.0",
55+
"@commitlint/config-conventional": "^20.0.0",
56+
"@openapi-typescript-infra/coconfig": "^4.7.1",
57+
"@openapi-typescript-infra/service": "^6.0.0",
5858
"@semantic-release/changelog": "^6.0.3",
59-
"@semantic-release/commit-analyzer": "^13.0.0",
60-
"@semantic-release/exec": "^6.0.3",
59+
"@semantic-release/commit-analyzer": "^13.0.1",
60+
"@semantic-release/exec": "^7.1.0",
6161
"@semantic-release/git": "^10.0.1",
62-
"@semantic-release/release-notes-generator": "^14.0.1",
63-
"@types/node": "^22.7.7",
64-
"@typescript-eslint/eslint-plugin": "^8.10.0",
65-
"@typescript-eslint/parser": "^8.10.0",
66-
"@vitest/coverage-v8": "2.1.3",
67-
"coconfig": "^1.6.1",
68-
"eslint-config-prettier": "^9.1.0",
69-
"eslint-import-resolver-typescript": "^3.6.3",
70-
"eslint-plugin-import": "^2.31.0",
71-
"vitest": "2.1.3"
62+
"@semantic-release/release-notes-generator": "^14.1.0",
63+
"@types/node": "^24.10.0",
64+
"@typescript-eslint/eslint-plugin": "^8.46.2",
65+
"@typescript-eslint/parser": "^8.46.2",
66+
"@vitest/coverage-v8": "4.0.6",
67+
"coconfig": "^1.6.2",
68+
"eslint-config-prettier": "^10.1.8",
69+
"eslint-import-resolver-typescript": "^4.4.4",
70+
"eslint-plugin-import": "^2.32.0",
71+
"prettier": "^3.6.2",
72+
"vitest": "4.0.6"
7273
},
7374
"dependencies": {
74-
"@types/supertest": "^6.0.2",
75+
"@types/supertest": "^6.0.3",
7576
"eslint": "^8.57.1",
76-
"find-up": "^7.0.0",
77-
"pino-pretty": "^11.3.0",
77+
"find-up": "^8.0.0",
78+
"pino-pretty": "^13.1.2",
7879
"read-package-up": "^11.0.0",
79-
"supertest": "^7.0.0",
80-
"tsx": "^4.19.1",
81-
"typescript": "^5.6.3"
80+
"supertest": "^7.1.4",
81+
"tsx": "^4.20.6",
82+
"typescript": "^5.9.3"
8283
},
8384
"packageManager": "[email protected]"
8485
}

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ async function readOptions<
8787
}
8888

8989
class RequestTestingHelpers {
90-
constructor(private app: ServiceExpress) {
91-
}
90+
constructor(private app: ServiceExpress) {}
9291

9392
get request() {
9493
return request(this.app);
@@ -155,8 +154,10 @@ export async function clearReusableApp() {
155154
appService = undefined;
156155
try {
157156
if (oldListener) {
158-
return new Promise((resolve) => {
159-
oldListener?.close(resolve);
157+
return await new Promise((resolve) => {
158+
if (oldListener?.listening) {
159+
oldListener?.close(resolve);
160+
}
160161
});
161162
}
162163
} catch (error) {

0 commit comments

Comments
 (0)