Skip to content

A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.

chore: resolves out of memory error on jest test suite run

towfiqi73c2e145a1d8
diff --git a/backend/jest.config.ts b/backend/jest.config.ts
index 65d4750..8d3d64f 100644
--- a/backend/jest.config.ts
+++ b/backend/jest.config.ts
@@ -6,6 +6,10 @@ const config: Config = {
verbose: true,
clearMocks: true,
+ // Limit workers to prevent OOM and recycle workers that accumulate memory
+ maxWorkers: '50%',
+ workerIdleMemoryLimit: '512MB',
+
// Explicitly define the transform using ts-jest
transform: {
// This regex now tells Jest to use ts-jest for .ts, .tsx, .js, and .jsx files
diff --git a/backend/package.json b/backend/package.json
index dc30135..037f0ac 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -119,7 +119,7 @@
"lint": "eslint src/**/*.ts",
"migrate-db": "tsx -r dotenv/config src/db/migrate.ts",
"start": "node dist/index.js",
- "test": "jest --config jest.config.ts",
+ "test": "cross-env NODE_OPTIONS='--max-old-space-size=8192' jest --config jest.config.ts",
"build:pkg": "node ./scripts/build-pkg.js",
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});require('fs').rmSync('public',{recursive:true,force:true})\"",
"copy:frontend": "node -e \"const fs=require('fs');const path=require('path');const src='../frontend/dist';if(!fs.existsSync(src)){console.log('Skipping copy:frontend - frontend dist not found');process.exit(0)};function copyDir(s,d){fs.mkdirSync(d,{recursive:true});fs.readdirSync(s,{withFileTypes:true}).forEach(e=>{const sp=path.join(s,e.name),dp=path.join(d,e.name);e.isDirectory()?copyDir(sp,dp):fs.copyFileSync(sp,dp)})};copyDir(src,'public')\"",