Tests: Run tests in Edge in IE mode in GitHub Actions

While Edge in IE mode is not guaranteed to match IE 11 in every aspect,
in practice it generally does. Testing in this mode in GitHub Actions
will allow us to catch most IE-breaking issues at the PR level.

This change also adds missing npm scripts: `test:chrome`, `test:edge`
& `test:ie`.

Closes gh-5540
This commit is contained in:
Michał Gołębiowski-Owczarek 2024-09-09 18:24:28 +02:00 committed by GitHub
parent 4b7ecbad24
commit 6d78c0768d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 3 deletions

View File

@ -87,6 +87,34 @@ jobs:
- name: Run tests - name: Run tests
run: npm run ${{ matrix.NPM_SCRIPT }} run: npm run ${{ matrix.NPM_SCRIPT }}
ie:
runs-on: windows-latest
env:
NODE_VERSION: 20.x
name: test:ie - IE
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
- name: Install dependencies
run: npm install
- name: Run tests in Edge in IE mode
run: npm run test:ie
safari: safari:
runs-on: macos-latest runs-on: macos-latest
env: env:

View File

@ -71,7 +71,10 @@
"test:jsdom": "npm run pretest && npm run build:main && npm run test:unit -- -b jsdom -m basic", "test:jsdom": "npm run pretest && npm run build:main && npm run test:unit -- -b jsdom -m basic",
"test:node_smoke_tests": "npm run pretest && npm run build:all && node build/tasks/node_smoke_tests.js", "test:node_smoke_tests": "npm run pretest && npm run build:all && node build/tasks/node_smoke_tests.js",
"test:promises_aplus": "npm run build:main && node build/tasks/promises_aplus_tests.js", "test:promises_aplus": "npm run build:main && node build/tasks/promises_aplus_tests.js",
"test:chrome": "npm run pretest && npm run build:main && npm run test:unit -- -v -b chrome -h",
"test:edge": "npm run pretest && npm run build:main && npm run test:unit -- -v -b edge -h",
"test:firefox": "npm run pretest && npm run build:main && npm run test:unit -- -v -b firefox -h", "test:firefox": "npm run pretest && npm run build:main && npm run test:unit -- -v -b firefox -h",
"test:ie": "npm run pretest && npm run build:main && npm run test:unit -- -v -b ie",
"test:safari": "npm run pretest && npm run build:main && npm run test:unit -- -b safari", "test:safari": "npm run pretest && npm run build:main && npm run test:unit -- -b safari",
"test:server": "node test/runner/server.js", "test:server": "node test/runner/server.js",
"test:esm": "npm run pretest && npm run build:main && npm run test:unit -- --esm -h", "test:esm": "npm run pretest && npm run build:main && npm run test:unit -- --esm -h",

View File

@ -2,6 +2,7 @@ import { Builder, Capabilities, logging } from "selenium-webdriver";
import Chrome from "selenium-webdriver/chrome.js"; import Chrome from "selenium-webdriver/chrome.js";
import Edge from "selenium-webdriver/edge.js"; import Edge from "selenium-webdriver/edge.js";
import Firefox from "selenium-webdriver/firefox.js"; import Firefox from "selenium-webdriver/firefox.js";
import IE from "selenium-webdriver/ie.js";
import { browserSupportsHeadless } from "../lib/getBrowserString.js"; import { browserSupportsHeadless } from "../lib/getBrowserString.js";
// Set script timeout to 10min // Set script timeout to 10min
@ -9,9 +10,16 @@ const DRIVER_SCRIPT_TIMEOUT = 1000 * 60 * 10;
export default async function createDriver( { browserName, headless, url, verbose } ) { export default async function createDriver( { browserName, headless, url, verbose } ) {
const capabilities = Capabilities[ browserName ](); const capabilities = Capabilities[ browserName ]();
const prefs = new logging.Preferences();
prefs.setLevel( logging.Type.BROWSER, logging.Level.ALL ); // Support: IE 11+
capabilities.setLoggingPrefs( prefs ); // When those are set for IE, the process crashes with an error:
// "Unable to match capability set 0: goog:loggingPrefs is an unknown
// extension capability for IE".
if ( browserName !== "ie" ) {
const prefs = new logging.Preferences();
prefs.setLevel( logging.Type.BROWSER, logging.Level.ALL );
capabilities.setLoggingPrefs( prefs );
}
let driver = new Builder().withCapabilities( capabilities ); let driver = new Builder().withCapabilities( capabilities );
@ -49,6 +57,10 @@ export default async function createDriver( { browserName, headless, url, verbos
edgeOptions.setEdgeChromiumBinaryPath( process.env.EDGE_BIN ); edgeOptions.setEdgeChromiumBinaryPath( process.env.EDGE_BIN );
} }
const ieOptions = new IE.Options();
ieOptions.setEdgeChromium( true );
ieOptions.setEdgePath( "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" );
if ( headless ) { if ( headless ) {
chromeOptions.addArguments( "--headless=new" ); chromeOptions.addArguments( "--headless=new" );
firefoxOptions.addArguments( "--headless" ); firefoxOptions.addArguments( "--headless" );
@ -65,6 +77,7 @@ export default async function createDriver( { browserName, headless, url, verbos
.setChromeOptions( chromeOptions ) .setChromeOptions( chromeOptions )
.setFirefoxOptions( firefoxOptions ) .setFirefoxOptions( firefoxOptions )
.setEdgeOptions( edgeOptions ) .setEdgeOptions( edgeOptions )
.setIeOptions( ieOptions )
.build(); .build();
if ( verbose ) { if ( verbose ) {