Mangled exception handling with `chai-as-promised` leads to mocha silently exiting without reporting an error
See original GitHub issueI don’t know if this is supported or not, but it causes a very vicious silent error which causes the rest of the unit tests to not run and mocha to immediately exit with 0, reporting a global success - which means that automated unit testing doesn’t report any error
It is somewhat random, depending on the Node version - I have a repo that can reproduce it with 100% probability on Node 14 on Ubuntu 20.04
Normally ds.root.arrays.getAsync('time')
returns a Promise that resolves with a gdal.MDArray
It is a promisified function of a function that calls a callback
In this particular case getAsync()
is throwing synchronously from C++ and then proceeding to invoke its callback which causes the exception to be propagated in a very unusual way going higher up the chain.
it('should have "getAsync()" method', (done) => {
assert.eventually.instanceOf(ds.root.arrays.getAsync('time'), gdal.MDArray).then(done)
})
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
@sukrosono I think I found the problem: https://github.com/nodejs/node/issues/29355
@sukrosono I was able to reproduce the problem without any C++ shenanigans
mocha.test.js
.mocharc.json
If you run this test, mocha will silently exit with a 0 exit code, indicating success, upon hitting the exception. If the file contain other tests, they will be silently ignored.