Skip to content

Commit

Permalink
feat(testing): adding jest options for colors, reporters, verbose, co…
Browse files Browse the repository at this point in the history
…verage, coverageReporters, and
  • Loading branch information
Brian Martin authored and vsavkin committed Jul 3, 2019
1 parent e88baba commit 7a7ab9f
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/api-jest/builders/jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
22 changes: 22 additions & 0 deletions packages/jest/src/builders/jest/jest.impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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']
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions packages/jest/src/builders/jest/jest.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions packages/jest/src/builders/jest/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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)",
Expand Down

0 comments on commit 7a7ab9f

Please sign in to comment.