If Date.now is stubbed to return an invalid value an exception happens in reporter causing that no report is generated and exit code from mocha is 0 even a test failed.
I know that stubbing Date.now like this is not the best idea but I think an exception in reporter should not result in swallowing failed tests.
The exception happens at line _suiteAttr.timestamp = new Date(_suiteAttr.timestamp).toISOString().slice(0, -5); in MochaJUnitReporter.prototype.getXml() because _suiteAttr.timestamp is 9000000000000000 which is to high for new Date().
If
Date.now
is stubbed to return an invalid value an exception happens in reporter causing that no report is generated and exit code from mocha is 0 even a test failed.Reproducer:
I know that stubbing
Date.now
like this is not the best idea but I think an exception in reporter should not result in swallowing failed tests.The exception happens at line
_suiteAttr.timestamp = new Date(_suiteAttr.timestamp).toISOString().slice(0, -5);
inMochaJUnitReporter.prototype.getXml()
because_suiteAttr.timestamp
is9000000000000000
which is to high fornew Date()
.