Skip to content

Commit

Permalink
added playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LarWong committed Mar 13, 2024
1 parent db7ffdf commit 91476aa
Show file tree
Hide file tree
Showing 7 changed files with 652 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/test_perf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Perf Test

on: [push]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set-up OCaml
run: |
sudo apt update -y
sudo apt --assume-yes install curl m4 opam
export OPAMYES=1
opam init --compiler=ocaml-base-compiler.5.0.0
- name: Install dependencies
run: |
eval $(opam env)
export OPAMYES=1
make deps
- name: Install system dependencies
run: make deps

- name: Install project development dependencies
run: make dev

- name: Start web server in the background
run: make serve &
shell: bash

- name: Setup Node.js
uses: actions/setup-node@v3

- name: Install Playwright
run: npm install playwright

- name: Run Playwright test script
run: npx playwright test tests/simple.spec.js
5 changes: 5 additions & 0 deletions playwright-tests/.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/
14 changes: 14 additions & 0 deletions playwright-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "playwright-tests",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.42.1",
"@types/node": "^20.11.26"
}
}
79 changes: 79 additions & 0 deletions playwright-tests/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

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

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
/* 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: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 91476aa

Please sign in to comment.