Skip to content

Commit

Permalink
feat(testing): support for memory leaks detection for jest added [log…
Browse files Browse the repository at this point in the history
…HeapUsage, detectLeaks] (#9339)
  • Loading branch information
jepetko committed Mar 18, 2022
1 parent 05f72c9 commit cd8c9b0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
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

0 comments on commit cd8c9b0

Please sign in to comment.