mochawesome
mochawesome copied to clipboard
Context information is lost in final report when running in mocha parallel mode
Describe the bug Using addContext has no effect in final report when running tests in parallel using mocha 'parallel' mode
Code Reproduce run test in parallel mode with code to add context in report file. For instance :
const addContext = require("mochawesome/addContext")
...
describe("My testsuite", function () {
beforeEach(function () {
addContext(this, "this is a contextual info");
});
it("my test", function (done) {
expect(true).to.be.true;
});
});
Expected behavior Context should be added in testcase when expanding test in HTML report, this works well when we run tests not in parallel mode (--parallel)
Have the same issue!
Try running Mocha with --require mochawesome/register
.
I can confirm that using require("mochawesome/register");
inside .test.js file is solving the problem.
It would be really nice if it worked without that tho...
--require mochawesome/register
It helps. Thanks, man!
You're amazing, guys)
You do not need to use require("mochawesome/register");
in the all tests. There is a simpler way to make it happen:
mocha -r mochawesome/register
It's not working for me :(
Here's the run with --parallel flag - hooks are not logging the context
And here's the one without - hooks are logging the context this time
Is there something else I need to do particularly for typescript ?
Hi @joo920131,
I have restored your example in a demo project but I could not reproduce the issue of not attaching context in parallel mode.
Could you please provide the code to reproduce? Thanks.
the above commandline requirement worked for me thanks! might be worth adding to the docs
PRs welcome