【发布时间】:2020-11-24 21:44:34
【问题描述】:
我有以下测试,我想在其中发出一个特定事件,即 unhandledRejection 过程:
describe('Processes Tests', () => {
afterEach(() => {
sinon.restore();
});
it('Check unhandledRejection process Spied On', () => {
var spy = sinon.spy();
process.on('unhandledRejection', spy);
process.emit('unhandledRejection');
sinon.assert.calledOnce(spy);
});
});
我在process.emit('unhandledRejection')这一行出现以下错误:
Argument of type '"unhandledRejection"' is not assignable to parameter of type '"disconnect"'.
可能有人知道这是为什么以及我如何能够解决它以便我可以测试这个过程?提前致谢!
【问题讨论】:
标签: node.js typescript mocha.js chai sinon