Skip to content

Commit

Permalink
feat(builders): add runInBand and maxWorkers options to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Sep 11, 2018
1 parent 99f4434 commit 8cbc5b4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/builders/src/jest/jest.builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ describe('Jest Builder', () => {
ci: true,
updateSnapshot: true,
onlyChanged: true,
passWithNoTests: true
passWithNoTests: true,
runInBand: true,
maxWorkers: 2
}
})
.toPromise();
Expand All @@ -84,7 +86,9 @@ describe('Jest Builder', () => {
ci: true,
updateSnapshot: true,
onlyChanged: true,
passWithNoTests: true
passWithNoTests: true,
runInBand: true,
maxWorkers: 2
},
['./jest.config.js']
);
Expand Down
7 changes: 7 additions & 0 deletions packages/builders/src/jest/jest.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export interface JestBuilderOptions {
ci?: boolean;
codeCoverage?: boolean;
onlyChanged?: boolean;
maxWorkers?: number;
passWithNoTests?: boolean;
runInBand?: boolean;
setupFile?: string;
updateSnapshot?: boolean;
}
Expand All @@ -35,6 +37,7 @@ export default class JestBuilder implements Builder<JestBuilderOptions> {
updateSnapshot: options.updateSnapshot,
onlyChanged: options.onlyChanged,
passWithNoTests: options.passWithNoTests,
runInBand: options.runInBand,
globals: JSON.stringify({
'ts-jest': {
tsConfigFile: path.relative(builderConfig.root, options.tsConfig)
Expand All @@ -43,6 +46,10 @@ export default class JestBuilder implements Builder<JestBuilderOptions> {
})
};

if (options.maxWorkers) {
config.maxWorkers = options.maxWorkers;
}

if (options.setupFile) {
config.setupTestFrameworkScriptFile = path.join(
'<rootDir>',
Expand Down
10 changes: 10 additions & 0 deletions packages/builders/src/jest/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
"type": "boolean",
"description":
"Fail on missing snapshots. (https://jestjs.io/docs/en/cli#ci)"
},
"runInBand": {
"type": "boolean",
"description":
"Run tests in a single process as opposed to multiple workers. Useful for CI. (https://jestjs.io/docs/en/cli.html#runinband)"
},
"maxWorkers": {
"type": "number",
"description":
"Max number of workers to run tests across. Useful for CI. (https://jestjs.io/docs/en/cli.html#maxworkers-num)"
}
},
"required": ["jestConfig", "tsConfig"]
Expand Down

0 comments on commit 8cbc5b4

Please sign in to comment.