Skip to content

Commit

Permalink
test(@astrojs/node) listen for server setup errors in test-utils (wit…
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton authored and PeterDraex committed Apr 23, 2024
1 parent 587d0c2 commit a2428eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/integrations/node/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

0 comments on commit a2428eb

Please sign in to comment.