mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
test(@astrojs/node) listen for server setup errors in test-utils (#10692)
This commit is contained in:
parent
e300ac9b9d
commit
ab153fd888
1 changed files with 10 additions and 3 deletions
|
@ -66,9 +66,16 @@ export function buffersToString(buffers) {
|
|||
}
|
||||
|
||||
export function waitServerListen(server) {
|
||||
return new Promise((resolve) => {
|
||||
server.on('listening', () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
function onListen() {
|
||||
server.off('error', onError);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
function onError(error) {
|
||||
server.off('listening', onListen);
|
||||
reject(error);
|
||||
}
|
||||
server.once('listening', onListen);
|
||||
server.once('error', onError);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue