diff --git a/docs/generated/api-jest/executors/jest.md b/docs/generated/api-jest/executors/jest.md index 488927c417574..d409e4918751b 100644 --- a/docs/generated/api-jest/executors/jest.md +++ b/docs/generated/api-jest/executors/jest.md @@ -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` @@ -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 diff --git a/packages/jest/src/executors/jest/jest.impl.spec.ts b/packages/jest/src/executors/jest/jest.impl.spec.ts index 3c4413ff9e70c..42b2e7dc7f333 100644 --- a/packages/jest/src/executors/jest/jest.impl.spec.ts +++ b/packages/jest/src/executors/jest/jest.impl.spec.ts @@ -172,6 +172,8 @@ describe('Jest Executor', () => { color: false, ci: true, detectOpenHandles: true, + logHeapUsage: true, + detectLeaks: true, json: true, maxWorkers: 2, onlyChanged: true, @@ -204,6 +206,8 @@ describe('Jest Executor', () => { color: false, ci: true, detectOpenHandles: true, + logHeapUsage: true, + detectLeaks: true, json: true, maxWorkers: 2, onlyChanged: true, diff --git a/packages/jest/src/executors/jest/jest.impl.ts b/packages/jest/src/executors/jest/jest.impl.ts index af3dea675bce4..dd857b394995f 100644 --- a/packages/jest/src/executors/jest/jest.impl.ts +++ b/packages/jest/src/executors/jest/jest.impl.ts @@ -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, diff --git a/packages/jest/src/executors/jest/schema.d.ts b/packages/jest/src/executors/jest/schema.d.ts index 3b4395a10767a..3c3e4b9f929b8 100644 --- a/packages/jest/src/executors/jest/schema.d.ts +++ b/packages/jest/src/executors/jest/schema.d.ts @@ -2,6 +2,8 @@ export interface JestExecutorOptions { codeCoverage?: boolean; config?: string; detectOpenHandles?: boolean; + logHeapUsage?: boolean; + detectLeaks?: boolean; jestConfig: string; testFile?: string; setupFile?: string; diff --git a/packages/jest/src/executors/jest/schema.json b/packages/jest/src/executors/jest/schema.json index 22417ed09f2fc..c08b5ee67c453 100644 --- a/packages/jest/src/executors/jest/schema.json +++ b/packages/jest/src/executors/jest/schema.json @@ -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"