Skip to content

Commit

Permalink
Playwright + Native Node Test Runner (#3893)
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam authored Dec 17, 2023
1 parent f24c358 commit 996ff28
Show file tree
Hide file tree
Showing 23 changed files with 5,753 additions and 9,215 deletions.
17 changes: 0 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,6 @@ module.exports = {
}
},

// Override for jest puppeteer
{
"files": [
"**/*.spec.js",
"**/*.spec.jsx"
],
env: {
jest: true,
},
globals: {
page: true,
browser: true,
context: true,
jestPuppeteer: true,
},
},

// Override for TypeScript
{
"files": [
Expand Down
31 changes: 8 additions & 23 deletions .github/workflows/auto-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
auto-test:
needs: [ check-linters ]
needs: [ check-linters, e2e-test ]
runs-on: ${{ matrix.os }}
timeout-minutes: 15

Expand All @@ -36,7 +36,7 @@ jobs:
- run: npm install npm@9 -g
- run: npm install
- run: npm run build
- run: npm test
- run: npm run test-backend
env:
HEADLESS_TEST: 1
JUST_FOR_TEST: ${{ secrets.JUST_FOR_TEST }}
Expand Down Expand Up @@ -78,33 +78,18 @@ jobs:
- run: npm install
- run: npm run lint:prod

# TODO: Temporarily disable, as it cannot pass the test in 2.0.0 yet
# e2e-tests:
# needs: [ check-linters ]
# runs-on: ubuntu-latest
# steps:
# - run: git config --global core.autocrlf false # Mainly for Windows
# - uses: actions/checkout@v4
#
# - name: Use Node.js 14
# uses: actions/setup-node@v4
# with:
# node-version: 14
# - run: npm install
# - run: npm run build
# - run: npm run cy:test

frontend-unit-tests:
e2e-test:
needs: [ check-linters ]
runs-on: ubuntu-latest
runs-on: ARM64
steps:
- run: git config --global core.autocrlf false # Mainly for Windows
- uses: actions/checkout@v4

- name: Use Node.js 14
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20
- run: npm install
- run: npx playwright install
- run: npm run build
- run: npm run cy:run:unit
- run: npm run test-e2e
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ dist-ssr
/tmp
.env

cypress/videos
cypress/screenshots

/extra/healthcheck.exe
/extra/healthcheck
/extra/healthcheck-armv7
Expand Down
60 changes: 60 additions & 0 deletions config/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { defineConfig, devices } from "@playwright/test";

const port = 30001;
const url = `http://localhost:${port}`;

export default defineConfig({
// Look for test files in the "tests" directory, relative to this configuration file.
testDir: "../test/e2e",
outputDir: "../private/playwright-test-results",
fullyParallel: false,
locale: "en-US",

// 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: 1,

// Reporter to use
reporter: [
[
"html", {
outputFolder: "../private/playwright-report",
open: "never",
}
],
],

use: {
// Base URL to use in actions like `await page.goto('/')`.
baseURL: url,

// Collect trace when retrying the failed test.
trace: "on-first-retry",
},

// Configure projects for major browsers.
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
/*
{
name: "firefox",
use: { browserName: "firefox" }
},*/
],

// Run your local dev server before starting the tests.
webServer: {
command: `node extra/remove-playwright-test-data.js && node server/server.js --port=${port} --data-dir=./data/playwright-test`,
url,
reuseExistingServer: false,
cwd: "../",
},
});
6 changes: 6 additions & 0 deletions extra/remove-playwright-test-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const fs = require("fs");

fs.rmSync("./data/playwright-test", {
recursive: true,
force: true,
});
Loading

0 comments on commit 996ff28

Please sign in to comment.