Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Jest Memory leaks #1043

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just ignore this file in eslint


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
Loading