Skip to content
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

WIP: Add Playwright tests #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Playwright Tests
on: [pull_request, workflow_dispatch]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
env:
PASSWORD: ${{ secrets.PASSWORD }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
.DS_Store
cypress.env.json

node_modules/

cypress.env.json
cypress/downloads/
cypress/screenshots/
cypress/videos/

test-results/
playwright-report/
blob-report/
playwright/.cache/
89 changes: 78 additions & 11 deletions package-lock.json

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

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"cy:open:prod": "cypress open --env environment=prod",
"test": "cypress run --record false --browser chrome",
"test:prod": "cypress run --record false --browser chrome --env environment=prod",
"test:prod:cloud": "cypress run --browser chrome --record --tag 'prod' --env environment=prod"
"test:prod:cloud": "cypress run --browser chrome --record --tag 'prod' --env environment=prod",
"pw:open": "playwright test --ui"
},
"keywords": [
"Cypress Playground",
Expand All @@ -20,8 +21,11 @@
"author": "Walmyr <wlsf82@gmail.com> (https://walmyr.dev/)",
"license": "MIT",
"devDependencies": {
"@playwright/test": "^1.49.1",
"@types/node": "^22.10.2",
"axe-core": "^4.10.2",
"cypress": "^13.17.0",
"cypress-axe": "^1.5.0"
"cypress-axe": "^1.5.0",
"lodash": "^4.17.21"
}
}
42 changes: 42 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test')

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config({ path: path.resolve(__dirname, '.env') })

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
/* 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,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* 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'] },
},
],
})

1 change: 1 addition & 0 deletions tests/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!
Loading
Loading