Skip to content

Commit

Permalink
Fix Jest Memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Feb 4, 2025
1 parent 519afd8 commit f707834
Show file tree
Hide file tree
Showing 18 changed files with 1,015 additions and 455 deletions.
4 changes: 3 additions & 1 deletion apps/charterafrica/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"start": "PAYLOAD_CONFIG_PATH=${PAYLOAD_CONFIG_PATH:-dist/payload.config.js} NODE_ENV=${NODE_ENV:-production} node dist/server.js",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"playwright": "npx playwright test",
"clean": "rm -rf .next .turbo build dist node_modules",
"db-migrate": "migrate-mongo up",
Expand Down Expand Up @@ -86,6 +86,8 @@
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@babel/register": "catalog:",
"@babel/runtime": "catalog:",
Expand Down
4 changes: 3 additions & 1 deletion apps/civicsignalblog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dev": "NODE_OPTIONS='--inspect --conditions=dev' TS_NODE_PROJECT=tsconfig.server.json tsx server.ts",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 next lint --fix './'",
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"playwright": "npx playwright test",
"clean": "rm -rf .next .turbo build dist node_modules"
},
Expand Down Expand Up @@ -82,6 +82,8 @@
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/testing-library": "workspace:*",
"@playwright/test": "catalog:",
Expand Down
3 changes: 2 additions & 1 deletion apps/climatemappedafrica/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev": "NODE_OPTIONS='--inspect' TS_NODE_PROJECT=tsconfig.server.json tsx server.ts",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"playwright": "npx playwright test",
"clean": "rm -rf .next .turbo build dist node_modules"
},
Expand Down Expand Up @@ -90,6 +90,7 @@
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/testing-library": "workspace:*",
Expand Down
4 changes: 3 additions & 1 deletion apps/codeforafrica/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev": "NODE_OPTIONS='--inspect' TS_NODE_PROJECT=tsconfig.server.json tsx server.ts",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"playwright": "npx playwright test",
"clean": "rm -rf .next .turbo node_modules"
},
Expand Down Expand Up @@ -74,6 +74,8 @@
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/testing-library": "workspace:*",
"@playwright/test": "catalog:",
Expand Down
3 changes: 2 additions & 1 deletion apps/pesayetu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"storybook": "storybook dev -p 6006",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"jest": "jest --passWithNoTests",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit --passWithNoTests",
"playwright": "npx playwright test",
"build": "next build",
"start": "next start",
Expand Down Expand Up @@ -77,6 +77,7 @@
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/testing-library": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions apps/promisetracker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/testing-library": "workspace:*",
Expand Down
4 changes: 3 additions & 1 deletion apps/roboshield/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "PAYLOAD_CONFIG_PATH=${PAYLOAD_CONFIG_PATH:-dist/payload.config.js} NODE_ENV=${NODE_ENV:-production} node dist/server.js",
"dev": "NODE_OPTIONS='--inspect' TS_NODE_PROJECT=tsconfig.server.json tsx server.ts",
"clean": "rm -rf .next .turbo node_modules",
"jest": "jest --passWithNoTests",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit --passWithNoTests",
"lint-check": "TIMING=1 next lint './'",
"lint": "TIMING=1 next lint --fix './'",
"generate:types": "payload generate:types"
Expand Down Expand Up @@ -58,6 +58,8 @@
"tsconfig-paths": "catalog:"
},
"devDependencies": {
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@commons-ui/testing-library": "workspace:*",
"@svgr/webpack": "catalog:",
"@types/express": "catalog:",
Expand Down
2 changes: 2 additions & 0 deletions apps/techlabblog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"shiki": "catalog:"
},
"devDependencies": {
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@svgr/webpack": "catalog:",
"@types/mdx": "catalog:",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion apps/vpnmanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint-check": "TIMING=1 next lint './'",
"lint": "TIMING=1 next lint --fix './'",
"clean": "rm -rf .next .turbo node_modules",
"jest": "jest --passWithNoTests",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit --passWithNoTests",
"playwright": "npx playwright test"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/commons-ui-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"url": "https://github.com/codeforafrica/ui/issues"
},
"scripts": {
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"clean": "rm -rf .turbo node_modules dist"
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/testing-library": "workspace:*",
"@emotion/react": "catalog:",
Expand Down
4 changes: 3 additions & 1 deletion packages/commons-ui-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"url": "https://github.com/codeforafrica/ui/issues"
},
"scripts": {
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"clean": "rm -rf .turbo node_modules dist"
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/core": "workspace:*",
"@commons-ui/testing-library": "workspace:*",
Expand Down
4 changes: 3 additions & 1 deletion packages/commons-ui-payload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"url": "https://github.com/codeforafrica/ui/issues"
},
"scripts": {
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"clean": "rm -rf .turbo node_modules dist"
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/core": "workspace:*",
"@commons-ui/next": "workspace:*",
Expand Down
6 changes: 6 additions & 0 deletions packages/commons-ui-testing-library/force-gc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-env jest */
/* eslint-disable no-undef */

afterEach(() => {
if (global.gc) global.gc();
});
1 change: 1 addition & 0 deletions packages/commons-ui-testing-library/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import "@testing-library/jest-dom";
import "./force-gc";
4 changes: 3 additions & 1 deletion packages/hurumap-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
"url": "https://github.com/codeforafrica/ui/issues"
},
"scripts": {
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"clean": "rm -rf .turbo node_modules dist"
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/core": "workspace:*",
"@commons-ui/testing-library": "workspace:*",
Expand Down
4 changes: 3 additions & 1 deletion packages/hurumap-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
"url": "https://github.com/codeforafrica/ui/issues"
},
"scripts": {
"jest": "jest",
"jest": "node --expose-gc --max-old-space-size=4096 node_modules/jest/bin/jest.js --coverage --runInBand --logHeapUsage --forceExit",
"lint-check": "TIMING=1 eslint './'",
"lint": "TIMING=1 eslint --flag unstable_config_lookup_from_file --fix './'",
"clean": "rm -rf .turbo node_modules dist"
},
"devDependencies": {
"@babel/core": "catalog:",
"@babel/plugin-transform-private-methods": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-react": "catalog:",
"@commons-ui/core": "workspace:*",
"@commons-ui/next": "workspace:*",
Expand Down
Loading

0 comments on commit f707834

Please sign in to comment.