-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathplaywright.e2e.config.ts
41 lines (37 loc) · 1.62 KB
/
playwright.e2e.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { defineConfig, type PlaywrightTestConfig } from "@playwright/test";
import commonConfig from "./playwright.common.config";
function returnWebserverCommand(): string {
if (process.env.CI) {
// CI: use existing backend build, reset and seed database
const binary = process.platform === "win32" ? "..\\builds\\backend\\abacus.exe" : "../builds/backend/abacus";
return `${binary} --reset-database --seed-data --port 8081`;
} else if (process.env.LOCAL_CI) {
// LOCAL CI: build frontend, then build and run backend with database reset and seed playwright-specific database
return `npm run build &&
cd ../backend &&
npx cross-env ASSET_DIR=$PWD/../frontend/dist cargo run --features memory-serve -- --database target/debug/playwright.sqlite --reset-database --seed-data --port 8081`;
} else {
// DEV: expects frontend build and playwright-specific database setup/seeding to have been done
return `cd ../backend && npx cross-env ASSET_DIR=$PWD/../frontend/dist cargo run --features memory-serve -- --database ../backend/target/debug/playwright.sqlite --port 8081`;
}
}
const config: PlaywrightTestConfig = defineConfig({
...commonConfig,
reporter: process.env.CI
? [["list"], ["github"], ["junit", { outputFile: "playwright.ladle.junit.xml" }], ["html", { open: "never" }]]
: "list",
testDir: "./e2e-tests",
outputDir: "./test-results/e2e-tests",
testMatch: /\.e2e\.ts/,
use: {
...commonConfig.use,
baseURL: "http://127.0.0.1:8081",
},
webServer: [
{
command: returnWebserverCommand(),
url: "http://127.0.0.1:8081",
},
],
});
export default config;