Skip to content

Commit 1c566b5

Browse files
authored
test: Fix node integration tests sharing SDK initializations (#5715)
1 parent 9c01fcc commit 1c566b5

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

packages/node-integration-tests/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ module.exports = {
44
globalSetup: '<rootDir>/utils/setup-tests.ts',
55
...baseConfig,
66
testMatch: ['**/test.ts'],
7+
setupFilesAfterEnv: ['./jest.setup.js'],
78
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Increases test timeout from 5s to 45s
2+
jest.setTimeout(45000);

packages/node-integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"fix:prettier": "prettier --write \"{suites,utils}/**/*.ts\"",
1818
"type-check": "tsc",
1919
"pretest": "run-s --silent prisma:init",
20-
"test": "jest --runInBand --forceExit",
20+
"test": "jest --forceExit",
2121
"test:watch": "yarn test --watch"
2222
},
2323
"dependencies": {

packages/node-integration-tests/utils/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,9 @@ export class TestEnv {
137137
* @return {*} {Promise<string>}
138138
*/
139139
public static async init(testDir: string, serverPath?: string, scenarioPath?: string): Promise<TestEnv> {
140-
const port = await getPortPromise();
141-
const url = `http://localhost:${port}/test`;
142140
const defaultServerPath = path.resolve(process.cwd(), 'utils', 'defaults', 'server');
143141

144-
const server = await new Promise<http.Server>(resolve => {
142+
const [server, url] = await new Promise<[http.Server, string]>(resolve => {
145143
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
146144
const app = require(serverPath || defaultServerPath).default as Express;
147145

@@ -153,8 +151,11 @@ export class TestEnv {
153151
}
154152
});
155153

156-
const server = app.listen(port, () => {
157-
resolve(server);
154+
void getPortPromise().then(port => {
155+
const url = `http://localhost:${port}/test`;
156+
const server = app.listen(port, () => {
157+
resolve([server, url]);
158+
});
158159
});
159160
});
160161

0 commit comments

Comments
 (0)