From 033a3c043233686d4c984d30d511730286113628 Mon Sep 17 00:00:00 2001 From: kira-pilot Date: Wed, 29 Jun 2022 17:02:03 +0000 Subject: [PATCH] chore: adding some quality of life Playwright comments --- site/e2e/constants.ts | 4 ++++ site/e2e/globalSetup.ts | 2 +- site/e2e/playwright.config.ts | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/site/e2e/constants.ts b/site/e2e/constants.ts index a8617434bf78b..af78e67958883 100644 --- a/site/e2e/constants.ts +++ b/site/e2e/constants.ts @@ -1,3 +1,7 @@ +// Our base port. It's important to run on 3000, +// which matches our api server +export const basePort = 3000 + // Credentials for the default user when running in dev mode. export const username = "developer" export const password = "password" diff --git a/site/e2e/globalSetup.ts b/site/e2e/globalSetup.ts index 2ad1195439aed..76405f82bdb71 100644 --- a/site/e2e/globalSetup.ts +++ b/site/e2e/globalSetup.ts @@ -3,7 +3,7 @@ import { postFirstUser } from "../src/api/api" import * as constants from "./constants" const globalSetup = async (): Promise => { - axios.defaults.baseURL = "http://localhost:3000" + axios.defaults.baseURL = `http://localhost:${constants.basePort}` await postFirstUser({ email: constants.email, organization: constants.organization, diff --git a/site/e2e/playwright.config.ts b/site/e2e/playwright.config.ts index bd0a6ea4a6518..a9d0fdc4bbd44 100644 --- a/site/e2e/playwright.config.ts +++ b/site/e2e/playwright.config.ts @@ -1,5 +1,6 @@ import { PlaywrightTestConfig } from "@playwright/test" import * as path from "path" +import { basePort } from "./constants" const config: PlaywrightTestConfig = { testDir: "tests", @@ -8,8 +9,11 @@ const config: PlaywrightTestConfig = { // Create junit report file for upload to DataDog reporter: [["junit", { outputFile: "test-results/junit.xml" }]], + // NOTE: if Playwright complains about the port being taken + // do not change the basePort (it must match our api server). + // Instead, simply run the test suite without running our local server. use: { - baseURL: "http://localhost:3000", + baseURL: `http://localhost:${basePort}`, video: "retain-on-failure", }, @@ -21,7 +25,7 @@ const config: PlaywrightTestConfig = { __dirname, "../../cmd/coder/main.go", )} server --in-memory`, - port: 3000, + port: basePort, timeout: 120 * 10000, reuseExistingServer: false, },