Skip to content

Commit

Permalink
adding github playwright yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremieflrnt committed Dec 4, 2023
1 parent b621463 commit 3039cf2
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 33 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Playwright Tests
on:
push:
branches: [main, master, feat/github-actions-playwright]
pull_request:
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.40.0-jammy
defaults:
run:
working-directory: ./playwright
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install --with-deps
- name: Run your tests
run: PLAYWRIGHT_BROWSERS_PATH=node_modules/playwright-core/.local-browsers npx playwright test
env:
HOME: /root
ENVIRONMENT: production
- uses: actions/upload-artifact@v3
if: always()
with:
name: out-report
path: out/report/
retention-days: 30
48 changes: 24 additions & 24 deletions playwright/package-lock.json

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

4 changes: 2 additions & 2 deletions playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"test": "playwright test"
},
"devDependencies": {
"@playwright/test": "1.39",
"@playwright/test": "1.40.1",
"@types/node": "17.0.35",
"eslint": "8.42.0",
"eslint-plugin-playwright": "0.12.0",
"playwright": "1.39",
"playwright": "1.40.1",
"ts-node": "10.7.0",
"typescript": "4.6.4"
}
Expand Down
11 changes: 6 additions & 5 deletions playwright/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ReporterDescription, defineConfig, devices } from '@playwright/test';
import fs from 'fs';
import { PW_AUTH_FILE } from './tests/auth.setup';

export const PW_AUTH_FILE = '.auth/user.json';

const getBaseUrl = (): string => {
return process.env.ENVIRONMENT === 'production' ? 'https://beleffort.vercel.app' : 'http://localhost:3000';
return process.env.ENVIRONMENT === 'production' ? 'https://beleffort.app' : 'http://localhost:3000';
};

const getReportersList = (): ReporterDescription[] => {
Expand Down Expand Up @@ -58,7 +59,7 @@ export default defineConfig({
deviceScaleFactor: 2,
storageState: PW_AUTH_FILE,
},
dependencies: !fs.existsSync(PW_AUTH_FILE) ? ['setup'] : [],
// dependencies: !fs.existsSync(PW_AUTH_FILE) ? ['setup'] : [],
},
{
name: 'chrome small screen',
Expand All @@ -77,7 +78,7 @@ export default defineConfig({
deviceScaleFactor: 2,
storageState: PW_AUTH_FILE,
},
dependencies: !fs.existsSync(PW_AUTH_FILE) ? ['setup'] : [],
// dependencies: !fs.existsSync(PW_AUTH_FILE) ? ['setup'] : [],
},
{
name: 'safari', // https://yesviz.com/devices/macbookpro-16-2019/
Expand All @@ -88,7 +89,7 @@ export default defineConfig({
deviceScaleFactor: 2,
storageState: PW_AUTH_FILE,
},
dependencies: !fs.existsSync(PW_AUTH_FILE) ? ['setup'] : [],
// dependencies: !fs.existsSync(PW_AUTH_FILE) ? ['setup'] : [],
},
{
name: 'iPhone 13 Pro',
Expand Down
3 changes: 1 addition & 2 deletions playwright/tests/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { test as setup } from '@playwright/test';

export const PW_AUTH_FILE = '.auth/user.json';
import { PW_AUTH_FILE } from '../playwright.config';

setup('authenticate', async ({ page }) => {
const nameCookie =
Expand Down

0 comments on commit 3039cf2

Please sign in to comment.