Skip to content

Commit

Permalink
chore(SPV-1105): run visual tests in docker
Browse files Browse the repository at this point in the history
thanks by that screenshots will be consistent between the repository and github actions (linux)
  • Loading branch information
swierzbicki authored and dorzepowski committed Oct 22, 2024
1 parent 31017d5 commit f4084e1
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
run: yarn install --frozen-lockfile --immutable

- name: Run Playwright tests
run: yarn test:visual
run: npx playwright test -c playwright.config.ts

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"build": "tsc && vite build",
"lint": "eslint --report-unused-disable-directives --max-warnings 0",
"test:unit": "vitest --config ./vitest.config.unit.ts",
"test:visual": "playwright test -c playwright.config.ts",
"test:visual:update": "playwright test --update-snapshots",
"test:visual": "docker compose -f ./playwright/docker-compose.yaml up playwright-tests --build",
"test:visual:update": "docker compose -f ./playwright/docker-compose.yaml up playwright-update-tests --build",
"coverage": "vitest run --coverage",
"preview": "vite preview",
"prettier:check": "prettier --check 'src/**/*.{ts,tsx,js,jsx,json,css}'",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { GitHubActionOptions } from '@estruyf/github-actions-reporter';
*/
export default defineConfig({
testDir: './src/__tests__',
snapshotPathTemplate: '{testDir}/{testFileDir}/__screenshoots__/{testName}/{arg}{ext}',
snapshotPathTemplate: '{testDir}/visual/__screenshoots__/{testName}/{platform}/{arg}-{projectName}{ext}',
expect: {
// Maximum time expect() should wait for the condition to be met.
timeout: 5000,
Expand Down
13 changes: 13 additions & 0 deletions playwright/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:22-bookworm-slim

RUN npx -y [email protected] install --with-deps

WORKDIR /app

COPY package.json ./
COPY yarn.lock ./

RUN yarn install

COPY . .

20 changes: 20 additions & 0 deletions playwright/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
playwright-tests:
build:
context: ./..
dockerfile: playwright/Dockerfile
volumes:
- ../src/__tests__/visual/__screenshoots__:/app/src/__tests__/visual/__screenshoots__
- ../playwright-report:/app/playwright-report
- ../test-results:/app/test-results
command: npx playwright test --reporter=html
environment:
CI: false

playwright-update-tests:
build:
context: ./..
dockerfile: playwright/Dockerfile
volumes:
- ../src/__tests__/visual/__screenshoots__:/app/src/__tests__/visual/__screenshoots__
command: npx playwright test --update-snapshots
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/__tests__/visual/xpubs/xpubs-page.visual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ test.describe('xpubs page', () => {
await route.fulfill({ json });
});

await page.waitForLoadState('domcontentloaded');

await expect(page).toHaveScreenshot();
});
});

0 comments on commit f4084e1

Please sign in to comment.