Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarah committed May 5, 2024
1 parent f3c8fce commit 9ef162d
Show file tree
Hide file tree
Showing 7 changed files with 597 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
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
run: npm run test:e2e:ci -w e2e-test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
5 changes: 5 additions & 0 deletions apps/e2e-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
18 changes: 18 additions & 0 deletions apps/e2e-test/e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from '@playwright/test';

Check failure on line 1 in apps/e2e-test/e2e/example.spec.ts

View workflow job for this annotation

GitHub Actions / test

Replace `·test,·expect·` with `test,·expect`

Check failure on line 1 in apps/e2e-test/e2e/example.spec.ts

View workflow job for this annotation

GitHub Actions / test

"@playwright/test" is not published

test('has title', async ({ page }) => {

Check failure on line 3 in apps/e2e-test/e2e/example.spec.ts

View workflow job for this annotation

GitHub Actions / test

Replace `·page·` with `page`
await page.goto('https://playwright.dev/');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) => {

Check failure on line 10 in apps/e2e-test/e2e/example.spec.ts

View workflow job for this annotation

GitHub Actions / test

Replace `·page·` with `page`
await page.goto('https://playwright.dev/');

// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();

Check failure on line 14 in apps/e2e-test/e2e/example.spec.ts

View workflow job for this annotation

GitHub Actions / test

Replace `·name:·'Get·started'·` with `name:·'Get·started'`

// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();

Check failure on line 17 in apps/e2e-test/e2e/example.spec.ts

View workflow job for this annotation

GitHub Actions / test

Replace `·name:·'Installation'·` with `name:·'Installation'`
});
12 changes: 12 additions & 0 deletions apps/e2e-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "e2e-test",
"version": "1.0.0",
"description": "A Playwright testing app",
"scripts": {
"test:e2e:ci": "playwright test"
},
"devDependencies": {
"@playwright/test": "^1.43.1",
"@types/node": "^20.12.8"
}
}
77 changes: 77 additions & 0 deletions apps/e2e-test/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {defineConfig, devices} from '@playwright/test';

Check failure on line 1 in apps/e2e-test/playwright.config.ts

View workflow job for this annotation

GitHub Actions / test

"@playwright/test" is not published

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './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,

Check failure on line 17 in apps/e2e-test/playwright.config.ts

View workflow job for this annotation

GitHub Actions / test

CI is not listed as a dependency in turbo.json
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,

Check failure on line 19 in apps/e2e-test/playwright.config.ts

View workflow job for this annotation

GitHub Actions / test

CI is not listed as a dependency in turbo.json
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,

Check failure on line 21 in apps/e2e-test/playwright.config.ts

View workflow job for this annotation

GitHub Actions / test

CI is not listed as a dependency in turbo.json
/* 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']},
},

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

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

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

0 comments on commit 9ef162d

Please sign in to comment.