-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process signals #11
Comments
Hi! Could you give an example of your request? I'm not entirely sure if you intend to mock the event listener, event emission, or something else. |
Alright! 🙂 process.on('SIGTERM', async () => {
// gracefulShutdown
})
process.on('SIGINT', async () => {
// gracefulShutdown
}) And you can trigger a signal with process.kill(process.pid, 'SIGINT'); The problem is program determinate when you test the signal even tho you mock the process exit. Would be nice to mock process.on and process.kill and simulate these signals pleasantly. Here is a simple test example. const mockProcess = require('jest-mock-process');
const mockedProcessOn = mockProcess.mockProcessOn();
registerSignalHandlers(app) // function to test
mockedProcessOn.sendSignal(process.pid, 'SIGINT')
expect(gracefulShutdown).toHaveBeenCalled();
mockedProcessOn.restoreMock()
// for another scenario
expect(mockedProcessOn).toHaveBeenCalledWith('Kill them all!'); https://nodejs.org/api/process.html#process_process_kill_pid_signal |
So there's no |
yes @CMCDragonkai |
Thanks for creating this module!
It would be awesome to have a mock for
process.on
with signal simulation.Sadly I don't have enough time right now but here is the issue.
The text was updated successfully, but these errors were encountered: