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

feat(testing): support for memory leaks detection added [logHeapUsage, detectLeaks] (#9338) #9339

Merged
merged 1 commit into from Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/generated/api-jest/executors/jest.md
Expand Up @@ -83,6 +83,12 @@ Type: `array`

A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter

### detectLeaks

Type: `boolean`

**EXPERIMENTAL**: Detect memory leaks in tests. After executing a test, it will try to garbage collect the global object used, and fail if it was leaked

### detectOpenHandles

Type: `boolean`
Expand All @@ -101,6 +107,12 @@ Type: `boolean`

Prints the test results in JSON. This mode will send all other test output and user messages to stderr. (https://jestjs.io/docs/cli#--json)

### logHeapUsage

Type: `boolean`

Logs the heap usage after every test. Useful to debug memory leaks. Use together with --runInBand and --expose-gc in node.

### maxWorkers

Alias(es): w
Expand Down
4 changes: 4 additions & 0 deletions packages/jest/src/executors/jest/jest.impl.spec.ts
Expand Up @@ -172,6 +172,8 @@ describe('Jest Executor', () => {
color: false,
ci: true,
detectOpenHandles: true,
logHeapUsage: true,
detectLeaks: true,
json: true,
maxWorkers: 2,
onlyChanged: true,
Expand Down Expand Up @@ -204,6 +206,8 @@ describe('Jest Executor', () => {
color: false,
ci: true,
detectOpenHandles: true,
logHeapUsage: true,
detectLeaks: true,
json: true,
maxWorkers: 2,
onlyChanged: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/jest/src/executors/jest/jest.impl.ts
Expand Up @@ -45,6 +45,8 @@ export async function jestConfigParser(
ci: options.ci,
color: options.color,
detectOpenHandles: options.detectOpenHandles,
logHeapUsage: options.logHeapUsage,
detectLeaks: options.detectLeaks,
json: options.json,
maxWorkers: options.maxWorkers,
onlyChanged: options.onlyChanged,
Expand Down
2 changes: 2 additions & 0 deletions packages/jest/src/executors/jest/schema.d.ts
Expand Up @@ -2,6 +2,8 @@ export interface JestExecutorOptions {
codeCoverage?: boolean;
config?: string;
detectOpenHandles?: boolean;
logHeapUsage?: boolean;
detectLeaks?: boolean;
jestConfig: string;
testFile?: string;
setupFile?: string;
Expand Down
8 changes: 8 additions & 0 deletions packages/jest/src/executors/jest/schema.json
Expand Up @@ -21,6 +21,14 @@
"description": "Attempt to collect and print open handles preventing Jest from exiting cleanly (https://jestjs.io/docs/cli#--detectopenhandles)",
"type": "boolean"
},
"logHeapUsage": {
"description": "Logs the heap usage after every test. Useful to debug memory leaks. Use together with --runInBand and --expose-gc in node.",
"type": "boolean"
},
"detectLeaks": {
"description": "**EXPERIMENTAL**: Detect memory leaks in tests. After executing a test, it will try to garbage collect the global object used, and fail if it was leaked",
"type": "boolean"
},
"jestConfig": {
"description": "The path of the Jest configuration. (https://jestjs.io/docs/en/configuration)",
"type": "string"
Expand Down