From 7a7ab9f2319c5f88ef0632ec76ea45d773e7685a Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 1 Jul 2019 21:51:59 -0400 Subject: [PATCH] feat(testing): adding jest options for colors, reporters, verbose, coverage, coverageReporters, and --- docs/api-jest/builders/jest.md | 38 +++++++++++++++++++ .../jest/src/builders/jest/jest.impl.spec.ts | 22 +++++++++++ packages/jest/src/builders/jest/jest.impl.ts | 11 ++++++ packages/jest/src/builders/jest/schema.json | 24 ++++++++++++ 4 files changed, 95 insertions(+) diff --git a/docs/api-jest/builders/jest.md b/docs/api-jest/builders/jest.md index 6e02cebf54e1a..8039286c33942 100644 --- a/docs/api-jest/builders/jest.md +++ b/docs/api-jest/builders/jest.md @@ -32,10 +32,36 @@ Indicates that test coverage information should be collected and reported in the ### color +Alias(es): colors + Type: `boolean` Forces test results output color highlighting (even if stdout is not a TTY). Set to false if you would like to have no colors. (https://jestjs.io/docs/en/cli#colors) +### colors + +Type: `boolean` + +Forces test results output highlighting even if stdout is not a TTY. (https://jestjs.io/docs/en/cli#colors) + +### coverage + +Type: `boolean` + +Indicates that test coverage information should be collected and reported in the output. This option is also aliased by --collectCoverage. (https://jestjs.io/docs/en/cli#coverage) + +### coverageDirectory + +Type: `string` + +An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path matches any of the patterns, coverage information will be skipped. + +### coverageReporters + +Type: `string` + +A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter + ### jestConfig Type: `string` @@ -76,6 +102,12 @@ Type: `boolean` Will not fail if no tests are found (for example while using `--testPathPattern`.) (https://jestjs.io/docs/en/cli#passwithnotests) +### reporters + +Type: `string` + +Run tests with specified reporters. Reporter options are not available via CLI. Example with multiple reporters: jest --reporters="default" --reporters="jest-junit" (https://jestjs.io/docs/en/cli#reporters) + ### runInBand Alias(es): i @@ -130,6 +162,12 @@ Type: `boolean` Divert all output to stderr. +### verbose + +Type: `string` + +Display individual test results with the test suite hierarchy. (https://jestjs.io/docs/en/cli#verbose) + ### watch Type: `boolean` diff --git a/packages/jest/src/builders/jest/jest.impl.spec.ts b/packages/jest/src/builders/jest/jest.impl.spec.ts index 64b5897af526a..00adca27eef2e 100644 --- a/packages/jest/src/builders/jest/jest.impl.spec.ts +++ b/packages/jest/src/builders/jest/jest.impl.spec.ts @@ -70,6 +70,12 @@ describe('Jest Builder', () => { codeCoverage: false, runInBand: true, testNamePattern: 'should load', + colors: false, + reporters: '/test/path', + verbose: false, + coverage: false, + coverageReporters: 'test', + coverageDirectory: '/test/path', watch: false }); expect(await run.result).toEqual( @@ -96,6 +102,11 @@ describe('Jest Builder', () => { coverage: false, runInBand: true, testNamePattern: 'should load', + colors: false, + reporters: '/test/path', + verbose: false, + coverageReporters: 'test', + coverageDirectory: '/test/path', watch: false }, ['/root/jest.config.js'] @@ -117,6 +128,12 @@ describe('Jest Builder', () => { passWithNoTests: true, silent: true, testNamePattern: 'test', + colors: false, + reporters: '/test/path', + verbose: false, + coverage: false, + coverageReporters: 'test', + coverageDirectory: '/test/path', updateSnapshot: true, useStderr: true, watch: false, @@ -152,6 +169,11 @@ describe('Jest Builder', () => { passWithNoTests: true, silent: true, testNamePattern: 'test', + colors: false, + verbose: false, + reporters: '/test/path', + coverageReporters: 'test', + coverageDirectory: '/test/path', updateSnapshot: true, useStderr: true, watch: false, diff --git a/packages/jest/src/builders/jest/jest.impl.ts b/packages/jest/src/builders/jest/jest.impl.ts index 7b7c655ba8856..2cde47784c6f5 100644 --- a/packages/jest/src/builders/jest/jest.impl.ts +++ b/packages/jest/src/builders/jest/jest.impl.ts @@ -34,6 +34,12 @@ export interface JestBuilderOptions extends JsonObject { runInBand?: boolean; silent?: boolean; testNamePattern?: string; + colors?: boolean; + reporters?: string; + verbose?: false; + coverage?: false; + coverageReporters?: string; + coverageDirectory?: string; updateSnapshot?: boolean; useStderr?: boolean; watch?: boolean; @@ -80,6 +86,11 @@ function run( runInBand: options.runInBand, silent: options.silent, testNamePattern: options.testNamePattern, + colors: options.colors, + reporters: options.reporters, + verbose: options.verbose, + coverageReporters: options.coverageReporters, + coverageDirectory: options.coverageDirectory, updateSnapshot: options.updateSnapshot, useStderr: options.useStderr, watch: options.watch, diff --git a/packages/jest/src/builders/jest/schema.json b/packages/jest/src/builders/jest/schema.json index aa0f3eab2caa5..b33499a3a0f51 100644 --- a/packages/jest/src/builders/jest/schema.json +++ b/packages/jest/src/builders/jest/schema.json @@ -37,6 +37,7 @@ "type": "boolean" }, "color": { + "alias": "colors", "description": "Forces test results output color highlighting (even if stdout is not a TTY). Set to false if you would like to have no colors. (https://jestjs.io/docs/en/cli#colors)", "type": "boolean" }, @@ -76,6 +77,29 @@ "description": "Run only tests with a name that matches the regex pattern. (https://jestjs.io/docs/en/cli#testnamepattern-regex)", "type": "string" }, + "colors": { + "description": "Forces test results output highlighting even if stdout is not a TTY. (https://jestjs.io/docs/en/cli#colors)", + "type": "boolean" + }, + "reporters": { + "description": "Run tests with specified reporters. Reporter options are not available via CLI. Example with multiple reporters: jest --reporters=\"default\" --reporters=\"jest-junit\" (https://jestjs.io/docs/en/cli#reporters)", + "type": "string" + }, + "verbose": { + "description": "Display individual test results with the test suite hierarchy. (https://jestjs.io/docs/en/cli#verbose)" + }, + "coverage": { + "description": "Indicates that test coverage information should be collected and reported in the output. This option is also aliased by --collectCoverage. (https://jestjs.io/docs/en/cli#coverage)", + "type": "boolean" + }, + "coverageReporters": { + "description": "A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter", + "type": "string" + }, + "coverageDirectory": { + "description": "An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path matches any of the patterns, coverage information will be skipped.", + "type": "string" + }, "updateSnapshot": { "alias": "u", "description": "Use this flag to re-record snapshots. Can be used together with a test suite pattern or with `--testNamePattern` to re-record snapshot for test matching the pattern. (https://jestjs.io/docs/en/cli#updatesnapshot)",