I need to conduct a test on the warning process for my Typescript project. The specific code that I am attempting to test is shown below:
process.on('warning', (warning) => {
LoggingService.info('Warning, Message: ' + warning.message + ' Stack: ' + warning.stack, 'warning');
});
To carry out the test, I am utilizing sinnon.spy
in the following manner:
it('Verify warning process', (done) => {
const spy = sinon.spy(LoggingService, 'info');
process.on('uncaughtException', () => {
sinon.assert.calledWith(spy, "warning")
done()
})
process.emit('warning')
})
However, I encountered an error with the test case above:
Argument of type '"warning"' is not assignable to parameter of type '"disconnect"'.
How can I go about resolving this error, given that the warning process is defined in the code under test? Any assistance would be truly appreciated!