Skip to content

Commit

Permalink
Add playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods committed Aug 9, 2024
1 parent e654e7d commit e37dc6f
Show file tree
Hide file tree
Showing 8 changed files with 351 additions and 24 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,24 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: lts/*
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run check
- run: npm run test

e2e_test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'npm'
- run: npm ci
- run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- run: npx playwright test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
node_modules

dist
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
139 changes: 116 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"format": "prettier . --ignore-path .gitignore --write",
"postformat": "eslint . --fix",
"test": "npm run check && vitest",
"e2e": "playwright test --project chromium",
"check": "tsc --noEmit",
"dev": "vite",
"build": "vite build",
Expand All @@ -19,6 +20,8 @@
},
"devDependencies": {
"@eslint/js": "^9.8.0",
"@playwright/test": "^1.46.0",
"@types/node": "^22.1.0",
"@typescript/lib-dom": "npm:@types/web@^0.0.151",
"@vitejs/plugin-legacy": "^5.4.1",
"eslint": "^9.8.0",
Expand Down
58 changes: 58 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { defineConfig, devices } from '@playwright/test';

const webServer = false;

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests/e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
use: {
baseURL: webServer ? 'http://127.0.0.1:4173' : 'https://maskable.app/',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
},
],

/* Run your local dev server before starting the tests */
webServer: webServer
? {
command: 'npm run preview',
url: 'http://127.0.0.1:4173',
reuseExistingServer: !process.env.CI,
}
: undefined,
});
Loading

0 comments on commit e37dc6f

Please sign in to comment.