Skip to content

Commit fb281ca

Browse files
committed
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 jquerygh-5540 (cherry picked from commit 6d78c07)
1 parent 6c7f755 commit fb281ca

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

.github/workflows/node.js.yml

+28
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@ jobs:
8787
- name: Run tests
8888
run: npm run ${{ matrix.NPM_SCRIPT }}
8989

90+
ie:
91+
runs-on: windows-latest
92+
env:
93+
NODE_VERSION: 20.x
94+
name: test:ie - IE
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
98+
99+
- name: Use Node.js ${{ env.NODE_VERSION }}
100+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
101+
with:
102+
node-version: ${{ env.NODE_VERSION }}
103+
104+
- name: Cache
105+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
106+
with:
107+
path: ~/.npm
108+
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
109+
restore-keys: |
110+
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
111+
112+
- name: Install dependencies
113+
run: npm install
114+
115+
- name: Run tests in Edge in IE mode
116+
run: npm run test:ie
117+
90118
safari:
91119
runs-on: macos-latest
92120
env:

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
"test:jsdom": "npm run pretest && npm run build:main && npm run test:unit -- -b jsdom -m basic",
3131
"test:node_smoke_tests": "npm run pretest && npm run build:all && node build/tasks/node_smoke_tests.js",
3232
"test:promises_aplus": "npm run build:main && node build/tasks/promises_aplus_tests.js",
33+
"test:chrome": "npm run pretest && npm run build:main && npm run test:unit -- -v -b chrome -h",
34+
"test:edge": "npm run pretest && npm run build:main && npm run test:unit -- -v -b edge -h",
3335
"test:firefox": "npm run pretest && npm run build:main && npm run test:unit -- -v -b firefox -h",
36+
"test:ie": "npm run pretest && npm run build:main && npm run test:unit -- -v -b ie",
3437
"test:safari": "npm run pretest && npm run build:main && npm run test:unit -- -b safari",
3538
"test:server": "node test/runner/server.js",
3639
"test:amd": "npm run pretest && npm run build:main && npm run test:unit -- --amd -h",

test/runner/selenium/createDriver.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@ import { Builder, Capabilities, logging } from "selenium-webdriver";
22
import Chrome from "selenium-webdriver/chrome.js";
33
import Edge from "selenium-webdriver/edge.js";
44
import Firefox from "selenium-webdriver/firefox.js";
5+
import IE from "selenium-webdriver/ie.js";
56
import { browserSupportsHeadless } from "../lib/getBrowserString.js";
67

78
// Set script timeout to 10min
89
const DRIVER_SCRIPT_TIMEOUT = 1000 * 60 * 10;
910

1011
export default async function createDriver( { browserName, headless, url, verbose } ) {
1112
const capabilities = Capabilities[ browserName ]();
12-
const prefs = new logging.Preferences();
13-
prefs.setLevel( logging.Type.BROWSER, logging.Level.ALL );
14-
capabilities.setLoggingPrefs( prefs );
13+
14+
// Support: IE 11+
15+
// When those are set for IE, the process crashes with an error:
16+
// "Unable to match capability set 0: goog:loggingPrefs is an unknown
17+
// extension capability for IE".
18+
if ( browserName !== "ie" ) {
19+
const prefs = new logging.Preferences();
20+
prefs.setLevel( logging.Type.BROWSER, logging.Level.ALL );
21+
capabilities.setLoggingPrefs( prefs );
22+
}
1523

1624
let driver = new Builder().withCapabilities( capabilities );
1725

@@ -49,6 +57,10 @@ export default async function createDriver( { browserName, headless, url, verbos
4957
edgeOptions.setEdgeChromiumBinaryPath( process.env.EDGE_BIN );
5058
}
5159

60+
const ieOptions = new IE.Options();
61+
ieOptions.setEdgeChromium( true );
62+
ieOptions.setEdgePath( "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" );
63+
5264
if ( headless ) {
5365
chromeOptions.addArguments( "--headless=new" );
5466
firefoxOptions.addArguments( "--headless" );
@@ -65,6 +77,7 @@ export default async function createDriver( { browserName, headless, url, verbos
6577
.setChromeOptions( chromeOptions )
6678
.setFirefoxOptions( firefoxOptions )
6779
.setEdgeOptions( edgeOptions )
80+
.setIeOptions( ieOptions )
6881
.build();
6982

7083
if ( verbose ) {

0 commit comments

Comments
 (0)