Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(builders): add runInBand and maxWorkers options to jest #757

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -69,7 +69,9 @@ describe('Jest Builder', () => {
onlyChanged: true,
passWithNoTests: true,
bail: true,
silent: true
silent: true,
runInBand: true,
maxWorkers: 2
}
})
.toPromise();
Expand All @@ -88,7 +90,9 @@ describe('Jest Builder', () => {
onlyChanged: true,
passWithNoTests: true,
bail: true,
silent: true
silent: 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 @@ -19,7 +19,9 @@ export interface JestBuilderOptions {
ci?: boolean;
codeCoverage?: boolean;
onlyChanged?: boolean;
maxWorkers?: number;
passWithNoTests?: boolean;
runInBand?: boolean;
setupFile?: string;
silent?: boolean;
updateSnapshot?: boolean;
Expand All @@ -39,6 +41,7 @@ export default class JestBuilder implements Builder<JestBuilderOptions> {
onlyChanged: options.onlyChanged,
passWithNoTests: options.passWithNoTests,
silent: options.silent,
runInBand: options.runInBand,
globals: JSON.stringify({
'ts-jest': {
tsConfigFile: path.relative(builderConfig.root, options.tsConfig)
Expand All @@ -47,6 +50,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 @@ -59,6 +59,16 @@
"type": "boolean",
"description":
"Prevent tests from printing messages through the console. (https://jestjs.io/docs/en/cli#silent)"
},
"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