Skip to content

Commit 45269a4

Browse files
committed
Improved end to end test pipeline.
1 parent e5b0a19 commit 45269a4

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

.github/workflows/playwright.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
- name: Build project
3030
run: npm run build
3131
- name: Start Emulator
32-
run: firebase emulators:exec "npx playwright test --reporter=list" --project=demo-wordplay --only "firestore,hosting,auth"
32+
run: firebase emulators:exec "npx playwright test --reporter=list" --project=demo-wordplay --only "firestore,hosting,auth" --log-verbosity QUIET
3333
- uses: actions/upload-artifact@v4
3434
if: always()
3535
with:
3636
name: playwright-report
37-
path: playwright-report/
37+
path: test-results/
3838
retention-days: 30

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"check": "svelte-check --tsconfig ./tsconfig.json --watch .svelte-kit",
1111
"test": "vitest",
1212
"test:coverage": "vitest run --coverage",
13-
"end2end": "npm run build && firebase emulators:exec \"npx playwright test\" --project=demo-wordplay",
13+
"end2end": "npm run build && firebase emulators:exec \"npx playwright test\" --project=demo-wordplay --log-verbosity QUIET",
1414
"dev": "vite dev",
1515
"emu": "firebase emulators:start --project=demo-wordplay",
1616
"env": "run-script-os",

playwright.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default defineConfig({
3737
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
3838
use: {
3939
/* Base URL to use in actions like `await page.goto('/')`. */
40-
baseURL: 'http://localhost:4173',
40+
baseURL: 'http://127.0.0.1:5002',
4141
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
4242
trace: 'on-first-retry',
4343
viewport: { width: 1280, height: 720 },
@@ -55,11 +55,14 @@ export default defineConfig({
5555
/* Remove any lingering authentication state before starting the tests */
5656
webServer: {
5757
name: 'Vite build preview',
58-
command: 'rm -rf playwright/.auth && npm run preview',
59-
url: 'http://localhost:4173/',
58+
command: '',
59+
url: 'http://127.0.0.1:5002/',
6060
timeout: 180000,
6161
reuseExistingServer: !process.env.CI,
6262
stdout: 'pipe',
6363
stderr: 'pipe',
6464
},
65+
66+
/* Clean stuff up after tests */
67+
globalTeardown: './tests/teardown.ts',
6568
});

playwright/fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const test = baseTest.extend<{}, { workerStorageState: string }>({
2121

2222
// Important: make sure we authenticate in a clean environment by unsetting storage state.
2323
const page = await browser.newPage({
24-
baseURL: 'http://localhost:4173',
24+
baseURL: 'http://127.0.0.1:5002',
2525
});
2626

2727
// Acquire a unique account, for example create a new one.

tests/end2end/login.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { expect, test } from '../../playwright/fixtures';
22

33
test('verify default login, logout, and login form', async ({ page }) => {
4-
// Go to the join page.
4+
// fixtures.ts logins in the user prior to this.
5+
6+
// Go to the profile page and wait for the auth to load.
57
await page.goto('/profile');
68

79
// Verify that the profile username page is visible

tests/teardown.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import fs from 'fs';
2+
3+
export default function teardown() {
4+
fs.rmSync('playwright/.auth', { recursive: true, force: true });
5+
}

0 commit comments

Comments
 (0)