Skip to content

Commit bf4952c

Browse files
authored
fix: missing steps of test when running with workers (#4127)
1 parent 8ceb8be commit bf4952c

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

lib/command/run-workers.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = async function (workerCount, selectedRuns, options) {
1111
const passedTestArr = [];
1212
const failedTestArr = [];
1313
const skippedTestArr = [];
14+
const stepArr = [];
1415

1516
const { config: testConfig, override = '' } = options;
1617
const overrideConfigs = tryOrDefault(() => JSON.parse(override), {});
@@ -36,6 +37,14 @@ module.exports = async function (workerCount, selectedRuns, options) {
3637
suiteArr.push(suite);
3738
});
3839

40+
workers.on(event.step.passed, (step) => {
41+
stepArr.push(step);
42+
});
43+
44+
workers.on(event.step.failed, (step) => {
45+
stepArr.push(step);
46+
});
47+
3948
workers.on(event.test.failed, (test) => {
4049
failedTestArr.push(test);
4150
output.test.failed(test);
@@ -53,6 +62,28 @@ module.exports = async function (workerCount, selectedRuns, options) {
5362

5463
workers.on(event.all.result, () => {
5564
// expose test stats after all workers finished their execution
65+
function addStepsToTest(test, stepArr) {
66+
stepArr.test.steps.forEach(step => {
67+
if (test.steps.length === 0) {
68+
test.steps.push(step);
69+
}
70+
});
71+
}
72+
73+
stepArr.forEach(step => {
74+
passedTestArr.forEach(test => {
75+
if (step.test.title === test.title) {
76+
addStepsToTest(test, step);
77+
}
78+
});
79+
80+
failedTestArr.forEach(test => {
81+
if (step.test.title === test.title) {
82+
addStepsToTest(test, step);
83+
}
84+
});
85+
});
86+
5687
event.dispatcher.emit(event.workers.result, {
5788
suites: suiteArr,
5889
tests: {

lib/command/workers/runTests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function initializeListeners() {
132132
duration: test.duration || 0,
133133
err,
134134
parent,
135-
steps: test.steps ? simplifyStepsInTestObject(test.steps, err) : [],
135+
steps: test.steps && test.steps.length > 0 ? simplifyStepsInTestObject(test.steps, err) : [],
136136
};
137137
}
138138

@@ -161,7 +161,7 @@ function initializeListeners() {
161161
actor: step.actor,
162162
name: step.name,
163163
status: step.status,
164-
agrs: _args,
164+
args: _args,
165165
startedAt: step.startedAt,
166166
startTime: step.startTime,
167167
endTime: step.endTime,

0 commit comments

Comments
 (0)