Skip to content

Commit

Permalink
Allow parallel test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-ismagilov committed Jul 29, 2023
1 parent ca50f9d commit adfff9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 0 additions & 2 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ module.exports = defineConfig({
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests. */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down
19 changes: 14 additions & 5 deletions tests/capture.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ const contestConfigs = [

const backendCooldown = 2000;
const overlayDisplayDelay = 1000;
const address = "127.0.0.1:8080";
const baseURL = "http://" + address;
const address = "127.0.0.1";
const startingPort = 8080;

for (const contestConfig of contestConfigs) {
for (const [index, contestConfig] of contestConfigs.entries()) {
test(`config ${contestConfig}`, async ({ page }) => {
const childProcess = spawn("java", ["-jar", "artifacts/live-v3-dev.jar", "-P:auth.disabled=true", `-P:live.configDirectory=${contestConfig}`]);
const port = startingPort + index;
const baseURL = `http://${address}:${port}`;
const wsURL = `ws://${address}:${port}`;

const childProcess = spawn("java", [
"-jar",
"artifacts/live-v3-dev.jar",
`-port=${port}`,
"-P:auth.disabled=true",
`-P:live.configDirectory=${contestConfig}`]);

childProcess.stdout.on("data", (data) => {
console.log(`Child process stdout: ${data}`);
Expand All @@ -41,7 +50,7 @@ for (const contestConfig of contestConfigs) {

await page.waitForTimeout(backendCooldown);

let contestInfo = new WebSocket(`ws://${address}/api/overlay/contestInfo`);
let contestInfo = new WebSocket(`${wsURL}/api/overlay/contestInfo`);

const contestOver = new Promise((resolve) => {
if (contestInfo) {
Expand Down

0 comments on commit adfff9c

Please sign in to comment.