added parallelDescribes
This commit is contained in:
parent
3c39eb1dec
commit
f65196ff0f
|
|
@ -401,7 +401,7 @@ class JobDispatcher {
|
|||
// - there are no remaining
|
||||
// - we are here not because something failed
|
||||
// - no unrecoverable worker error
|
||||
if (!this._remainingByTestId.size && !this._failedTests.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError) {
|
||||
if (!this._remainingByTestId.size && !this._failedTests.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError && !process.env.NON_ISOLATED_TESTS) {
|
||||
this._finished({ didFail: false });
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ export function createTestGroups(projectSuite: Suite, workers: number): TestGrou
|
|||
// These should run as a serial group, each group is independent, key === serial suite.
|
||||
parallel: Map<Suite | TestCase, TestGroup>,
|
||||
parallelWithHooks: TestGroup,
|
||||
parallelDescribes: Map<string, Array<TestCase>>,
|
||||
}>>();
|
||||
|
||||
const createGroup = (test: TestCase): TestGroup => {
|
||||
|
|
@ -73,6 +74,7 @@ export function createTestGroups(projectSuite: Suite, workers: number): TestGrou
|
|||
general: createGroup(test),
|
||||
parallel: new Map(),
|
||||
parallelWithHooks: createGroup(test),
|
||||
parallelDescribes: new Map(),
|
||||
};
|
||||
withWorkerHash.set(test._requireFile, withRequireFile);
|
||||
}
|
||||
|
|
@ -81,16 +83,28 @@ export function createTestGroups(projectSuite: Suite, workers: number): TestGrou
|
|||
let insideParallel = false;
|
||||
let outerMostSequentialSuite: Suite | undefined;
|
||||
let hasAllHooks = false;
|
||||
let hasDescribe = false;
|
||||
let currentTitle = '';
|
||||
for (let parent: Suite | undefined = test.parent; parent; parent = parent.parent) {
|
||||
if (parent._parallelMode === 'serial' || parent._parallelMode === 'default')
|
||||
outerMostSequentialSuite = parent;
|
||||
insideParallel = insideParallel || parent._parallelMode === 'parallel';
|
||||
hasAllHooks = hasAllHooks || parent._hooks.some(hook => hook.type === 'beforeAll' || hook.type === 'afterAll');
|
||||
hasDescribe = hasDescribe || parent.type === 'describe';
|
||||
if (parent._type === 'describe')
|
||||
currentTitle = parent.title;
|
||||
}
|
||||
|
||||
if (insideParallel) {
|
||||
if (hasAllHooks && !outerMostSequentialSuite) {
|
||||
if ((hasAllHooks && !outerMostSequentialSuite && !process.env.NON_ISOLATED_TESTS) || (!hasDescribe && process.env.NON_ISOLATED_TESTS)) {
|
||||
withRequireFile.parallelWithHooks.tests.push(test);
|
||||
} else if (hasDescribe && process.env.NON_ISOLATED_TESTS) {
|
||||
if (!withRequireFile.parallelDescribes.get(currentTitle)) {
|
||||
withRequireFile.parallelDescribes.set(currentTitle, [test]);
|
||||
} else {
|
||||
const value = withRequireFile.parallelDescribes.get(currentTitle);
|
||||
value?.push(test);
|
||||
}
|
||||
} else {
|
||||
const key = outerMostSequentialSuite || test;
|
||||
let group = withRequireFile.parallel.get(key);
|
||||
|
|
@ -125,6 +139,20 @@ export function createTestGroups(projectSuite: Suite, workers: number): TestGrou
|
|||
}
|
||||
lastGroup.tests.push(test);
|
||||
}
|
||||
if (process.env.NON_ISOLATED_TESTS) {
|
||||
const describeGroups = Array.from(withRequireFile.parallelDescribes, ([name, value]) => ({ name, value }));
|
||||
let lastDescribeGroup;
|
||||
for (const testGroup of describeGroups) {
|
||||
lastDescribeGroup = null;
|
||||
for (const test of testGroup.value) {
|
||||
if (!lastDescribeGroup) {
|
||||
lastDescribeGroup = createGroup(test);
|
||||
result.push(lastDescribeGroup);
|
||||
}
|
||||
lastDescribeGroup.tests.push(test);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Reference in a new issue