Skip to content

Commit

Permalink
chore(ci): add timeout to make sure the process ends
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzofox3 committed Dec 21, 2023
1 parent 4cec95e commit 7163b32
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions packages/core/test/run-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createServer } from 'vite';
import { firefox, chromium, webkit } from 'playwright';

const PORT = 3001;
const TIMEOUT = 30_000;

(async () => {
let server,
Expand All @@ -23,21 +24,30 @@ const PORT = 3001;
browsers.map((browser) => {
console.log(browser._name);
return new Promise((resolve, reject) => {
browser
.newPage()
.then((page) => {
page.on('websocket', (webSocket) => {
webSocket.on('framesent', ({ payload }) => {
const asJson = JSON.parse(payload);
if (asJson?.data?.type === 'STREAM_ENDED') {
resolve();
}
let timerId;
Promise.race([
browser
.newPage()
.then((page) => {
page.on('websocket', (webSocket) => {
webSocket.on('framesent', ({ payload }) => {
const asJson = JSON.parse(payload);
if (asJson?.data?.type === 'STREAM_ENDED') {
clearTimeout(timerId);
resolve();
}
});
});
});

return page.goto(`http://localhost:${PORT}/test/test-suite.html`);
})
.catch(reject);
return page.goto(
`http://localhost:${PORT}/test/test-suite.html`,
);
})
.catch(reject),
new Promise((resolve, reject) => {
timerId = setTimeout(() => reject('timeout'), TIMEOUT);
}),
]);
});
}),
);
Expand Down

0 comments on commit 7163b32

Please sign in to comment.