Skip to content

Commit

Permalink
Merge pull request #542 from theosanderson/playwright
Browse files Browse the repository at this point in the history
add playwright
  • Loading branch information
theosanderson authored Oct 12, 2023
2 parents 600f36e + f79541f commit 2f6b04e
Show file tree
Hide file tree
Showing 6 changed files with 2,464 additions and 1,897 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: NODE_OPTIONS='--max-old-space-size=4096' yarn install
working-directory: ./taxonium_website
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
working-directory: ./taxonium_website
- name: Build
run: yarn build
- name: Run Playwright tests
run: yarn 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
await page.waitForTimeout(1000);
// print the content of the page

console.log(await page.content());

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Taxonium/);
});
4 changes: 3 additions & 1 deletion taxonium_website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"preinstall": "cd ../taxonium_component && yarn install && yarn build",
"preinstall": "NODE_OPTIONS='--max-old-space-size=5096' cd ../taxonium_component && yarn install && yarn build",
"build": "vite build",
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
Expand All @@ -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
72 changes: 72 additions & 0 deletions taxonium_website/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// @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,
/* Opt out of parallel tests on CI. */
workers: 1,
/* 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",
port: 4173,
},
});
Loading

1 comment on commit 2f6b04e

@vercel
Copy link

@vercel vercel bot commented on 2f6b04e Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.