Skip to content

Commit 4d7dbae

Browse files
committed
Simplify playwright conifg
1 parent ba8dd49 commit 4d7dbae

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

site/e2e/constants.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Our base port. It's important to run on 3000,
2-
// which matches our api server
3-
export const basePort = 3000
1+
// Default port from the server
2+
export const defaultPort = 3000
43

54
// Credentials for the default user when running in dev mode.
65
export const username = "developer"

site/e2e/globalSetup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { createFirstUser } from "../src/api/api"
33
import * as constants from "./constants"
44

55
const globalSetup = async (): Promise<void> => {
6-
axios.defaults.baseURL = `http://localhost:${constants.basePort}`
7-
// Create a user
6+
axios.defaults.baseURL = `http://localhost:${constants.defaultPort}`
7+
// Create first user
88
await createFirstUser({
99
email: constants.email,
1010
username: constants.username,

site/e2e/playwright.config.ts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
import { PlaywrightTestConfig } from "@playwright/test"
2-
import * as path from "path"
3-
import { basePort } from "./constants"
2+
import path from "path"
3+
import { defaultPort } from "./constants"
4+
5+
const port = process.env.CODER_E2E_PORT
6+
? Number(process.env.CODER_E2E_PORT)
7+
: defaultPort
8+
9+
const coderMain = path.join(__dirname, "../../enterprise/cmd/coder/main.go")
410

511
const config: PlaywrightTestConfig = {
612
testDir: "tests",
713
globalSetup: require.resolve("./globalSetup"),
8-
9-
// Create junit report file for upload to DataDog
10-
reporter: [["junit", { outputFile: "test-results/junit.xml" }]],
11-
12-
// NOTE: if Playwright complains about the port being taken
13-
// do not change the basePort (it must match our api server).
14-
// Instead, simply run the test suite without running our local server.
1514
use: {
16-
baseURL: `http://localhost:${basePort}`,
15+
baseURL: `http://localhost:${port}`,
1716
video: "retain-on-failure",
1817
},
19-
20-
// `webServer` tells Playwright to launch a test server - more details here:
21-
// https://playwright.dev/docs/test-advanced#launching-a-development-web-server-during-the-tests
2218
webServer: {
23-
// Run the coder daemon directly.
24-
command: `go run -tags embed ${path.join(
25-
__dirname,
26-
"../../enterprise/cmd/coder/main.go",
27-
)} server --in-memory --access-url http://127.0.0.1:${basePort}`,
28-
port: basePort,
29-
timeout: 120 * 10000,
30-
reuseExistingServer: false,
19+
command: `go run -tags embed ${coderMain} server --global-config /tmp`,
20+
port,
3121
},
3222
}
3323

0 commit comments

Comments
 (0)