Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,56 @@ on:
workflow_dispatch:

jobs:
browser:
name: Test Browser
browser-macos:
name: Test Browser on macOS
runs-on: macos-latest
env:
GITHUB_ACTIONS_OUTPUT: ""
strategy:
fail-fast: false
matrix:
browser: [chrome, firefox, safari]
browser: [safari]
suite: [default, disabled, main]
steps:
- name: Extract Week Number
run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV

- name: Install Firefox
if: ${{ matrix.browser == 'firefox' }}
run: brew install --cask firefox

- name: Checkout Branch
- &checkout-branch
name: Checkout Branch
uses: actions/checkout@v5

- name: Setup Node
- &setup-node
name: Setup Node
uses: actions/setup-node@v5
with:
node-version-file: package.json
cache: npm

- name: Install Node Packages
- &install-node-packages
name: Install Node Packages
run: npm ci

- name: Run Tests
run: |
echo "Running in $BROWSER"
npm run test:${{ matrix.browser }} -- ${{ matrix.suite }}

browser-linux:
name: Test Browser on Linux
runs-on: ubuntu-latest
env:
GITHUB_ACTIONS_OUTPUT: ""
strategy:
fail-fast: false
matrix:
browser: [chrome, firefox]
suite: [default, disabled, main]
steps:
- *checkout-branch
- *setup-node
- *install-node-packages
- name: Run Tests
run: |
echo "Running in $BROWSER"
npm run test:${{ matrix.browser }} -- ${{ matrix.suite }}
shell:
name: Test Shell
runs-on: ubuntu-latest
Expand All @@ -55,21 +71,13 @@ jobs:
shell: [jsc, spidermonkey, v8]
suite: [default, disabled, main]
steps:
- *checkout-branch
- *setup-node
- *install-node-packages

- name: Extract Week Number
run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV

- name: Checkout Branch
uses: actions/checkout@v5

- name: Setup Node
uses: actions/setup-node@v5
with:
node-version-file: package.json
cache: npm

- name: Install Node Packages
run: npm ci

- name: Cache jsvu Binaries
uses: actions/cache@v4
with:
Expand All @@ -89,14 +97,8 @@ jobs:
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: npm

- name: Install Node Packages
run: npm ci
- *setup-node
- *install-node-packages

- name: Run Build
run: |
Expand Down
31 changes: 28 additions & 3 deletions tests/run-browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import serve from "./server.mjs";
import { Builder, Capabilities, logging } from "selenium-webdriver";
import { Options as ChromeOptions } from "selenium-webdriver/chrome.js";
import { Options as FirefoxOptions } from "selenium-webdriver/firefox.js";
import commandLineArgs from "command-line-args";
import { promises as fs } from "fs";
import path from "path";
Expand Down Expand Up @@ -95,20 +97,30 @@ if (options.suite && !VALID_TAGS.includes(options.suite))
const BROWSER = options?.browser;
if (!BROWSER)
printHelp("No browser specified, use $BROWSER or --browser", optionDefinitions);
const IS_HEADLESS = os.platform() === "linux" && !process.env.DISPLAY;

let capabilities;
let browserOptions;
switch (BROWSER) {
case "safari":
capabilities = Capabilities.safari();
capabilities.set("safari:diagnose", true);
break;

case "firefox": {
capabilities = Capabilities.firefox();
capabilities = Capabilities.firefox()
if (IS_HEADLESS) {
browserOptions = new FirefoxOptions();
browserOptions.addArguments("-headless");
}
break;
}
case "chrome": {
capabilities = Capabilities.chrome();
capabilities = Capabilities.chrome()
if (IS_HEADLESS) {
browserOptions = new ChromeOptions();
browserOptions.addArguments("--headless");
}
break;
}
case "edge": {
Expand Down Expand Up @@ -159,7 +171,20 @@ async function runEnd2EndTest(name, params) {
}

async function testEnd2End(params) {
const driver = await new Builder().withCapabilities(capabilities).build();
const builder = new Builder().withCapabilities(capabilities);
if (browserOptions) {
switch(BROWSER) {
case "firefox":
builder.setFirefoxOptions(browserOptions);
break;
case "chrome":
builder.setChromeOptions(browserOptions);
break;
default:
break;
}
}
const driver = await builder.build();
const sessionId = (await driver.getSession()).getId();
const driverCapabilities = await driver.getCapabilities();
logInfo(`Browser: ${driverCapabilities.getBrowserName()} ${driverCapabilities.getBrowserVersion()}`);
Expand Down
Loading