Skip to content

Commit

Permalink
Fix leak tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Oct 25, 2023
1 parent 901c33a commit 058818b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
collectCoverage: false,
globals: {
uwsUtils: require('./uwsUtils'),
libcurl: process.env.LEAK_TEST ? undefined : require('node-libcurl'),
libcurl: require('node-libcurl'),
},
cacheDirectory: resolve(ROOT_DIR, `${CI ? '' : 'node_modules/'}.cache/jest`),
resolver: 'bob-the-bundler/jest-resolver',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"prettier": "prettier --ignore-path .gitignore --ignore-path .prettierignore --write --list-different .",
"prettier:check": "prettier --ignore-path .gitignore --ignore-path .prettierignore --check .",
"release": "changeset publish",
"test": "jest --forceExit",
"test:leaks": "LEAK_TEST=1 jest --detectOpenHandles --detectLeaks --logHeapUsage --forceExit",
"test": "jest --runInBand --forceExit",
"test:leaks": "LEAK_TEST=1 jest --runInBand --detectOpenHandles --detectLeaks --logHeapUsage --forceExit",
"ts:check": "tsc --noEmit"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/test-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const libcurl = globalThis.libcurl;
export function runTestsForEachFetchImpl(callback: () => void) {
if (!process.env.LEAK_TEST) {
if (!libcurl) {
describe('libcurl', () => {
callback();
});
Expand Down
7 changes: 5 additions & 2 deletions packages/server/test/test-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ export function createNodeHttpTestServer(): Promise<TestServer> {
});
}

export const serverImplMap = {
export const serverImplMap: Record<string, () => Promise<TestServer>> = {
nodeHttp: createNodeHttpTestServer,
uWebSockets: createUWSTestServer,
};

if ((globalThis as any)['uwsUtils']) {
serverImplMap.uWebSockets = createUWSTestServer;
}

export function runTestsForEachServerImpl(callback: (server: TestServer) => void) {
for (const serverImplName in serverImplMap) {
describe(serverImplName, () => {
Expand Down

0 comments on commit 058818b

Please sign in to comment.