Skip to content

Commit

Permalink
fix: ts-jest memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Apr 18, 2021
1 parent 48423e7 commit 71f714d
Show file tree
Hide file tree
Showing 25 changed files with 115 additions and 59 deletions.
10 changes: 7 additions & 3 deletions core/jest-extract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"dependencies": {
"@component-controls/core": "^3.6.3",
"@component-controls/logger": "^2.10.4",
"babel-jest": "^26.4.4",
"babel-jest": "^26.6.3",
"fastq": "^1.11.0",
"jest": "^26.4.2",
"path": "^0.12.7",
"ts-jest": "^26.4.4"
"ts-jest": "^26.5.5"
},
"devDependencies": {
"@babel/preset-env": "^7.13.10",
Expand All @@ -60,11 +60,15 @@
"Atanas Stoyanov"
],
"jest": {
"preset": "ts-jest",
"transform": {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest"
},
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./test"
]
Expand Down
2 changes: 1 addition & 1 deletion core/jest-extract/src/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const runTestsWorker: fastq.asyncWorker<
{
rootDir: projectFolder,
testRegex: testFiles,
maxWorkers: 1,
forceExit: true,
testPathIgnorePatterns: ['/node_modules/', '/__snapshots__/'],
silent: true,
verbose: false,
Expand Down
14 changes: 0 additions & 14 deletions core/jest-extract/test/fixtures/simple/__jest-tmp-1/jest.config.js

This file was deleted.

14 changes: 0 additions & 14 deletions core/jest-extract/test/fixtures/simple/__jest-tmp-2/jest.config.js

This file was deleted.

14 changes: 0 additions & 14 deletions core/jest-extract/test/fixtures/simple/__jest-tmp-3/jest.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions examples/stories/src/tutorial/testing/jest-snapshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,20 @@ yarn add ts-jest @types/jest --dev
"scripts": {
...
"jest": {
// you can use a ts-jest preset
"preset": "ts-jest",
// or transforms for the used files
"transform": {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest"
},
"globals": {
// Temporary fix for memory leak in ts-jest, if your project is using typescript.
// https://github.com/kulshekhar/ts-jest/issues/1967.
"ts-jest": {
"isolatedModules": true
}
},
},
},
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"rollup": "^2.3.2",
"rollup-plugin-typescript2": "^0.27.0",
"trash-cli": "^3.0.0",
"ts-jest": "^26.4.4",
"ts-jest": "^26.5.5",
"ts-node": "^8.5.4",
"typescript": "^4.0.5"
},
Expand Down
5 changes: 5 additions & 0 deletions plugins/addon-catalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
]
Expand Down
5 changes: 5 additions & 0 deletions plugins/addon-images/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
],
Expand Down
5 changes: 5 additions & 0 deletions plugins/addon-notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
],
Expand Down
5 changes: 5 additions & 0 deletions plugins/addon-stats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
},
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
]
Expand Down
5 changes: 5 additions & 0 deletions plugins/axe-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
]
Expand Down
8 changes: 6 additions & 2 deletions plugins/cc-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@types/react-test-renderer": "^16.9.3",
"@types/testing-library__jest-dom": "^5.9.2",
"@wojtekmaj/enzyme-adapter-react-17": "^0.3.1",
"babel-jest": "^26.4.4",
"babel-jest": "^26.6.3",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.5.0",
"jest": "^26.4.2",
Expand All @@ -78,11 +78,15 @@
"Atanas Stoyanov"
],
"jest": {
"preset": "ts-jest",
"transform": {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest"
},
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./test"
]
Expand Down
5 changes: 3 additions & 2 deletions plugins/cc-cli/test/run-document-tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { runCLI } from 'jest';
import { Config } from '@jest/types';
import { createDocumentTemplate } from '../src/document-template';
import { StoryTemplateOptions } from '../src/types';

Expand Down Expand Up @@ -44,10 +43,12 @@ export const runTests = async (
{
testRegex: testName,
testPathIgnorePatterns: ['/node_modules/', '/__snapshots__/'],
detectOpenHandles: true,
runInBand: true,
silent: true,
verbose: false,
watchman: false,
} as Config.Argv,
} as any,
[__dirname],
);
} finally {
Expand Down
5 changes: 3 additions & 2 deletions plugins/cc-cli/test/run-store-tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { runCLI } from 'jest';
import { Config } from '@jest/types';
import { createStoreTemplate } from '../src/store-template';
import { TemplateOptions } from '../src/types';

Expand Down Expand Up @@ -38,10 +37,12 @@ export const runTests = async (props: TemplateOptions): Promise<void> => {
{
testRegex: testName,
testPathIgnorePatterns: ['/node_modules/', '/__snapshots__/'],
detectOpenHandles: true,
runInBand: true,
silent: true,
verbose: false,
watchman: false,
} as Config.Argv,
} as any,
[__dirname],
);
} finally {
Expand Down
6 changes: 4 additions & 2 deletions plugins/cc-cli/test/run-story-tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import { runCLI } from 'jest';
import { Config } from '@jest/types';
import { createStoriesTemplate } from '../src/stories-template';
import { StoryTemplateOptions } from '../src/types';

Expand Down Expand Up @@ -44,10 +43,13 @@ export const runTests = async (
{
testRegex: testName,
testPathIgnorePatterns: ['/node_modules/', '/__snapshots__/'],
detectOpenHandles: true,
runInBand: true,
forceExit: true,
silent: true,
verbose: false,
watchman: false,
} as Config.Argv,
} as any,
[__dirname],
);
} finally {
Expand Down
5 changes: 5 additions & 0 deletions plugins/figma-embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
]
Expand Down
5 changes: 5 additions & 0 deletions plugins/test-renderers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./test"
]
Expand Down
5 changes: 5 additions & 0 deletions plugins/viewport-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
]
Expand Down
5 changes: 5 additions & 0 deletions ui/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
],
Expand Down
5 changes: 5 additions & 0 deletions ui/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
],
Expand Down
7 changes: 4 additions & 3 deletions ui/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@
],
"jest": {
"preset": "ts-jest",
"transform": {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest"
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"moduleFileExtensions": [
"ts",
Expand Down
5 changes: 5 additions & 0 deletions ui/design-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
]
Expand Down
5 changes: 5 additions & 0 deletions ui/editors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
],
"jest": {
"preset": "ts-jest",
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"roots": [
"./src"
]
Expand Down
Loading

0 comments on commit 71f714d

Please sign in to comment.