You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For my integration tests I'm using mocha.parallel to speed up the tests. I'm using a custom-made mocha reporter that outputs the start and end time of a test in case of a failure to make it easier to go through the logs of my application. Sadly it seems that mocha.parallel doesn't set the start time correctly - the start time is set when the whole suite is started, not when the actual test is started. Also the duration seems to not always be set correctly. This results in an incorrect output of my mocha reporter.
Here is an example (the sleep function is basically a setTimeout which is wrapped in a promise):
Test Suit Collection
parallel suite 1
1) test 1 (Start: 09:09:00.921Z, End: 09:09:01.927Z)
2) test 2 (Start: 09:09:00.921Z, End: 09:09:00.921Z)
parallel suite 2
3) test 3 (Start: 09:09:00.921Z, End: 09:09:01.929Z)
4) test 4 (Start: 09:09:00.921Z, End: 09:09:00.921Z)
As you can see all tests have the same start time, even though the tests in parallel suite 2 should have started a second later. Also the duration in test 2 and 4 is not set correctly for some reason (I calculate the end time by adding the duration to the start time).
And this is part of my mocha reporter that creates the output above:
runner.on('fail', function (test) {
let startTime = this.stats["start"].toISOString().slice(11);
let endTime = (new Date(this.stats["start"].getTime() + test.duration)).toISOString().slice(11);
process.stdout.write(util.format(indent() + color('fail', ' %d) %s (Start: %s, End: %s)\n'),
++n, test.title, startTime, endTime));
});
I can't seem to find a workaround for this within my custom mocha reporter by listening to the 'test' event and save my own start time. mocha.parallel lead the mocha runner to believe that the tests run sequentially which in turn results in a sequential execution of the mocha reporter. I would get an output like this:
Test Suit Collection
parallel suite 1
1) test 1 (Start: 09:33:21.089Z, End: 09:33:22.093Z)
2) test 2 (Start: 09:33:22.098Z, End: 09:33:22.099Z)
parallel suite 2
3) test 3 (Start: 09:33:22.100Z, End: 09:33:23.101Z)
4) test 4 (Start: 09:33:23.103Z, End: 09:33:23.103Z)
I hope you can fix this sometimes soon. If not I'll try to fix this myself and make a pull request, if I find the time.
The text was updated successfully, but these errors were encountered:
For my integration tests I'm using mocha.parallel to speed up the tests. I'm using a custom-made mocha reporter that outputs the start and end time of a test in case of a failure to make it easier to go through the logs of my application. Sadly it seems that mocha.parallel doesn't set the start time correctly - the start time is set when the whole suite is started, not when the actual test is started. Also the duration seems to not always be set correctly. This results in an incorrect output of my mocha reporter.
Here is an example (the sleep function is basically a setTimeout which is wrapped in a promise):
Which outputs this with my mocha reporter:
As you can see all tests have the same start time, even though the tests in parallel suite 2 should have started a second later. Also the duration in test 2 and 4 is not set correctly for some reason (I calculate the end time by adding the duration to the start time).
And this is part of my mocha reporter that creates the output above:
I can't seem to find a workaround for this within my custom mocha reporter by listening to the 'test' event and save my own start time. mocha.parallel lead the mocha runner to believe that the tests run sequentially which in turn results in a sequential execution of the mocha reporter. I would get an output like this:
I hope you can fix this sometimes soon. If not I'll try to fix this myself and make a pull request, if I find the time.
The text was updated successfully, but these errors were encountered: