-
Notifications
You must be signed in to change notification settings - Fork 161
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
Changing the processing of parallel events #353
Conversation
src/mochawesome.js
Outdated
@@ -125,74 +116,24 @@ function Mochawesome(runner, options) { | |||
|
|||
let endCalled = false; | |||
|
|||
// Add a unique identifier to each suite/test/hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to remove this block? It is still needed by the reporter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamgruber, you're right, I have returned it back.
For some reason, I thought it was mine when I did parallel support.
PS: I have used the following code to cleanup volatile variables from the mochawsome.json with sync and parallel mode. const fs = require("fs");
const clean = (s) => {
if (s == null) {
return
}
if (Array.isArray(s)) {
s.forEach(clean);
} else if (typeof s === "object") {
for (let prop of Object.keys(s)) {
switch (prop) {
case "estack": {
if (typeof s[prop] === "string");
s[prop] = s[prop].slice(0, 50);
break;
}
case "start":
case "end":
case "uuid": {
if (typeof s[prop] === "string")
delete s[prop];
continue;
}
case "parentUUID": {
delete s[prop];
continue;
}
case "passes":
case "skipped":
case "failures": {
if (Array.isArray(s[prop]))
delete s[prop];
continue;
}
case "pending": {
if (Array.isArray(s[prop]) || s[prop] == null || s[prop] === false) {
delete s[prop];
continue;
}
break;
}
case "duration":
case "_timeout":
case "timedOut": {
delete s[prop];
continue;
}
}
clean(s[prop])
}
}
}
const make = (d) => {
const path = `mochawesome-report-${d}/mochawesome.json`
const p = JSON.parse(fs.readFileSync(path, { encoding: "utf8" }))
clean(p);
fs.writeFileSync(`mochawesome-${d}.json`, JSON.stringify(p, null, 2), { encoding: "utf8" })
}
make("p")
make("s")
console.log("done.") |
@adamgruber , how much is critical when the mochawesome.json in parallel mode does not contain parentUUID? |
|
Can you explain more what the code cleanup script does and why you need it? |
I have tried to compare the 2 mochawesome.json reports generated with parallel flag and without. |
I have marked as draft due to adjusting unit tests according to changes |
Hi, @adamgruber, could you please take a look at my changes? I have covered everything with unit tests |
Hi @adamgruber , thank you very much 🙇🏼 |
Purposes:
@juergba suggested to serialize tests in suites and listen to EVENT_SUITE_END event: #331 (comment)
This should allow to calculate the correct amount of SKIPPED tests.
I have tried to set
runner.linkPartialObjects(true)
and listen the EVENT_SUITE_END to recreate the suite's tree. It does not work for the nested suites if any hooks failed in the parent suite.Thus, the only solution was to make a full dump of the root suite and listen it in the EVENT_SUITE_END event.
The disadvantage of this is that a full dump is created twice for the EVENT_SUITE_BEGIN and EVENT_SUITE_AND events, which increases data transfer via IPC by 25%. For comparison, I have used
test-functional
tests, and the data transfer is 27.04 MB, when if a full dump was made once, it would be 22.17 MB.In additional:
Unrelated changes:
npm ci
instead ofnpm install
actions/setup-node@v2
withcache: 'npm'
option