-
-
Notifications
You must be signed in to change notification settings - Fork 548
Refactor tests to run Playwright's server in Docker #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,11 @@ | ||
| services: | ||
| serve-webpack-example: | ||
| build: | ||
| context: . | ||
| dockerfile: ./example/webpack/Dockerfile | ||
| stdin_open: true | ||
| tty: true | ||
| serve-express-example: | ||
| build: | ||
| context: . | ||
| dockerfile: ./example/express-server/Dockerfile | ||
| stdin_open: true | ||
| tty: true | ||
| test: | ||
| depends_on: | ||
| - serve-webpack-example | ||
| - serve-express-example | ||
| build: | ||
| context: . | ||
| dockerfile: ./tests/Dockerfile | ||
| volumes: | ||
| - ./demo-dist:/app/demo-dist:ro | ||
| - ./playwright.config.ts:/app/playwright.config.ts:ro | ||
| - ./tests:/app/tests | ||
| - ./test-results:/app/test-results | ||
| - ./playwright-report:/app/playwright-report | ||
| command: npx playwright test | ||
| update-snapshots: | ||
| depends_on: | ||
| - serve-webpack-example | ||
| - serve-express-example | ||
| playwright-server: | ||
| build: | ||
| context: . | ||
| dockerfile: ./tests/Dockerfile | ||
| volumes: | ||
| - ./demo-dist:/app/demo-dist:ro | ||
| - ./playwright.config.ts:/app/playwright.config.ts:ro | ||
| - ./tests:/app/tests | ||
| - ./test-results:/app/test-results | ||
| - ./playwright-report:/app/playwright-report | ||
| command: npx playwright test --update-snapshots | ||
| args: | ||
| PLAYWRIGHT_VERSION: ${PLAYWRIGHT_VERSION} | ||
| ipc: host | ||
| command: playwright run-server --host=0.0.0.0 --port=3000 | ||
| ports: | ||
| - '3000:3000' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,12 +1,15 @@ | ||||||
| import type { PlaywrightTestConfig } from '@playwright/test'; | ||||||
| import { devices } from '@playwright/test'; | ||||||
| import playwrightPackage from 'playwright/package.json' with { type: 'json' }; | ||||||
| import { devices, type PlaywrightTestConfig } from 'playwright/test'; | ||||||
|
|
||||||
IvanGoncharov marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| const isCI = !!process.env['CI']; | ||||||
| /** | ||||||
| * See https://playwright.dev/docs/test-configuration. | ||||||
| */ | ||||||
| const config: PlaywrightTestConfig = { | ||||||
| testDir: './tests', | ||||||
| // FIXME: remove '-linux' | ||||||
| snapshotPathTemplate: | ||||||
| '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}-linux{ext}', | ||||||
| /* Maximum time one test can run for. */ | ||||||
| timeout: 20 * 1000, | ||||||
| expect: { | ||||||
|
|
@@ -38,12 +41,17 @@ const config: PlaywrightTestConfig = { | |||||
|
|
||||||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||||||
| trace: 'retain-on-failure', | ||||||
|
|
||||||
| connectOptions: { | ||||||
| wsEndpoint: 'ws://127.0.0.1:3000/', | ||||||
| exposeNetwork: '<loopback>', | ||||||
| }, | ||||||
| }, | ||||||
| projects: [ | ||||||
| { | ||||||
| name: 'Demo', | ||||||
| testMatch: 'Demo.spec.ts', | ||||||
|
||||||
| testMatch: 'Demo.spec.ts', | |
| testMatch: 'demo.spec.ts', |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| FROM node:24 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY ["./package.json", "./package-lock.json", "./"] | ||
| RUN npm ci && npx playwright install --with-deps chromium | ||
|
|
||
| COPY ["./tsconfig.json", "./"] | ||
| COPY ["./scripts", "./scripts"] | ||
| ARG PLAYWRIGHT_VERSION="missing PLAYWRIGHT_VERSION arg" | ||
| RUN npm -g install "playwright@$PLAYWRIGHT_VERSION" && playwright install --with-deps chromium |
Uh oh!
There was an error while loading. Please reload this page.