I would like to test that the following function performs as expected:
function throwNextTick(error) {
process.nextTick(function () {
throw error;
Base on timoxley & Casey Foster, in node v6++
const assert = require('assert')
describe('throwNextTick', function() {
it('works as expected', function(next) {
function cb(err) {
assert.equal(err instanceof Error, true)
next()
}
function test(){
process.nextTick(() => {
throw new Error('err')
})
}
process.prependOnceListener('uncaughtException', cb)
test()
})
})