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: include 'runInBand' configuration #14857

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,12 @@ By default, `roots` has a single entry `<rootDir>` but there are cases where you

:::

### `runInBand` \[boolean]

Default: `false`

The equivalent of the [`--runInBand`](CLI.md#--runInBand) flag to run all tests serially in the current process.

### `runner` \[string]

Default: `"jest-runner"`
Expand Down
1 change: 1 addition & 0 deletions packages/jest-config/src/Defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const defaultOptions: Config.DefaultOptions = {
resetModules: false,
restoreMocks: false,
roots: ['<rootDir>'],
runInBand: false,
runTestsByPath: false,
runner: 'jest-runner',
setupFiles: [],
Expand Down
1 change: 1 addition & 0 deletions packages/jest-config/src/ValidConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const initialOptions: Config.InitialOptions = {
restoreMocks: false,
rootDir: '/',
roots: ['<rootDir>'],
runInBand: false,
runTestsByPath: false,
runner: 'jest-runner',
runtime: '<rootDir>',
Expand Down
8 changes: 8 additions & 0 deletions packages/jest-config/src/__tests__/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2175,4 +2175,12 @@ describe('runInBand', () => {
} as Config.Argv);
expect(options.runInBand).toBe(true);
});

test('respect options', async () => {
const {options} = await normalize(
{rootDir: '/root/', runInBand: true},
{} as Config.Argv,
);
expect(options.runInBand).toBe(true);
});
});
3 changes: 2 additions & 1 deletion packages/jest-config/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ export default async function normalize(
case 'resetModules':
case 'restoreMocks':
case 'rootDir':
case 'runInBand':
case 'runTestsByPath':
case 'sandboxInjectedGlobals':
case 'silent':
Expand Down Expand Up @@ -1098,7 +1099,7 @@ export default async function normalize(
10,
);
newOptions.maxWorkers = getMaxWorkers(argv, options);
newOptions.runInBand = argv.runInBand || false;
newOptions.runInBand = options.runInBand || argv.runInBand || false;

if (newOptions.testRegex.length > 0 && options.testMatch) {
throw createConfigError(
Expand Down
1 change: 1 addition & 0 deletions packages/jest-schemas/src/raw-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export const RawInitialOptions = Type.Partial(
rootDir: Type.String(),
roots: Type.Array(Type.String()),
runner: Type.String(),
runInBand: Type.Boolean(),
runTestsByPath: Type.Boolean(),
runtime: Type.String(),
sandboxInjectedGlobals: Type.Array(Type.String()),
Expand Down
1 change: 1 addition & 0 deletions packages/jest-types/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export type DefaultOptions = {
resetModules: boolean;
restoreMocks: boolean;
roots: Array<string>;
runInBand: boolean;
runTestsByPath: boolean;
runner: string;
setupFiles: Array<string>;
Expand Down
1 change: 1 addition & 0 deletions packages/jest-watcher/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type AllowedConfigOptions = Partial<
| 'testPathPatterns'
| 'updateSnapshot'
| 'verbose'
| 'runInBand'
> & {mode: 'watch' | 'watchAll'}
>;

Expand Down