diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..c672f96 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -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 diff --git a/playwright/package-lock.json b/playwright/package-lock.json index 6e98b23..ea8f601 100644 --- a/playwright/package-lock.json +++ b/playwright/package-lock.json @@ -8,11 +8,11 @@ "name": "beleffort-e2e", "version": "1.0.0", "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" } @@ -172,12 +172,12 @@ } }, "node_modules/@playwright/test": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz", - "integrity": "sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==", + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz", + "integrity": "sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw==", "dev": true, "dependencies": { - "playwright": "1.39.0" + "playwright": "1.40.1" }, "bin": { "playwright": "cli.js" @@ -1039,12 +1039,12 @@ } }, "node_modules/playwright": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.39.0.tgz", - "integrity": "sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==", + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.40.1.tgz", + "integrity": "sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw==", "dev": true, "dependencies": { - "playwright-core": "1.39.0" + "playwright-core": "1.40.1" }, "bin": { "playwright": "cli.js" @@ -1057,9 +1057,9 @@ } }, "node_modules/playwright-core": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", - "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.40.1.tgz", + "integrity": "sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ==", "dev": true, "bin": { "playwright-core": "cli.js" @@ -1474,12 +1474,12 @@ } }, "@playwright/test": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz", - "integrity": "sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==", + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz", + "integrity": "sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw==", "dev": true, "requires": { - "playwright": "1.39.0" + "playwright": "1.40.1" } }, "@tsconfig/node10": { @@ -2129,19 +2129,19 @@ "dev": true }, "playwright": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.39.0.tgz", - "integrity": "sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==", + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.40.1.tgz", + "integrity": "sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw==", "dev": true, "requires": { "fsevents": "2.3.2", - "playwright-core": "1.39.0" + "playwright-core": "1.40.1" } }, "playwright-core": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", - "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.40.1.tgz", + "integrity": "sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ==", "dev": true }, "prelude-ls": { diff --git a/playwright/package.json b/playwright/package.json index b4bcbd0..ac8a770 100644 --- a/playwright/package.json +++ b/playwright/package.json @@ -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" } diff --git a/playwright/playwright.config.ts b/playwright/playwright.config.ts index 1d4221e..7b45c00 100644 --- a/playwright/playwright.config.ts +++ b/playwright/playwright.config.ts @@ -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[] => { @@ -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', @@ -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/ @@ -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', diff --git a/playwright/tests/auth.setup.ts b/playwright/tests/auth.setup.ts index 19e9cb4..4bd38c1 100644 --- a/playwright/tests/auth.setup.ts +++ b/playwright/tests/auth.setup.ts @@ -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 =