add exception

This commit is contained in:
Simon Knott 2024-11-07 09:58:59 +01:00
parent a156cfe451
commit 970fad07e7
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 9 additions and 0 deletions

View file

@ -101,6 +101,8 @@ export class WebServerPlugin implements TestRunnerPlugin {
timeout = this._options.kill.SIGINT;
}
if ('SIGTERM' in this._options.kill && typeof this._options.kill.SIGTERM === 'number') {
if (signal)
throw new Error('Only one of SIGINT or SIGTERM can be specified in config.webServer.kill');
signal = 'SIGTERM';
timeout = this._options.kill.SIGTERM;
}

View file

@ -804,4 +804,11 @@ test.describe('kill option', () => {
expect(testProcess.outputLines({ prefix: '[WebServer] ' })).toEqual(['webserver received SIGINT but stubbornly refuses to wind down']);
});
test('throws when mixed', async ({ interactWithTestRunner }) => {
const testProcess = await interactWithTestRunner(files({ kill: { SIGINT: 500, SIGTERM: 500 } }), { workers: 1 });
await testProcess.exited;
expect(testProcess.output).toContain('Only one of SIGINT or SIGTERM can be specified in config.webServer.kill');
});
});