Skip to content

Commit

Permalink
add playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson committed Oct 12, 2023
1 parent 600f36e commit 6bee5b8
Show file tree
Hide file tree
Showing 6 changed files with 2,465 additions and 1,896 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn install
working-directory: ./taxonium_website
- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: ./taxonium_website
- name: Run Playwright tests
run: npx playwright test
working-directory: ./taxonium_website
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: ./taxonium_website/playwright-report/
retention-days: 30
3 changes: 3 additions & 0 deletions taxonium_website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?
/test-results/
/playwright-report/
/playwright/.cache/
14 changes: 14 additions & 0 deletions taxonium_website/e2e/example.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @ts-check
import { test, expect } from '@playwright/test';

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

await page.goto('//localhost:4173');
// wait a few seconds


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


2 changes: 2 additions & 0 deletions taxonium_website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"taxonium-component": "file:../taxonium_component"
},
"devDependencies": {
"@playwright/test": "^1.39.0",
"@types/node": "^20.8.4",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react": "^4.0.0",
Expand Down
78 changes: 78 additions & 0 deletions taxonium_website/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// @ts-check
import { defineConfig, devices } from '@playwright/test';

/**
* 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,
/* 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:4173',

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

webServer: {
command: 'yarn preview',
reuseExistingServer: !process.env.CI,
port: 4173,
},
});

Loading

0 comments on commit 6bee5b8

Please sign in to comment.