diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2024-09-09 18:24:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 18:24:28 +0200 |
commit | 6d78c0768d9aa6ba213678724c89af69a1958df6 (patch) | |
tree | 9a4b65317ac5af425710f8d9496cf05bfcbca0d9 | |
parent | 4b7ecbad24463c875f03ef4c7a7d307a091f93fd (diff) | |
download | jquery-6d78c0768d9aa6ba213678724c89af69a1958df6.tar.gz jquery-6d78c0768d9aa6ba213678724c89af69a1958df6.zip |
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
-rw-r--r-- | .github/workflows/node.js.yml | 28 | ||||
-rw-r--r-- | package.json | 3 | ||||
-rw-r--r-- | test/runner/selenium/createDriver.js | 19 |
3 files changed, 47 insertions, 3 deletions
diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 4b387cbe7..36dcf9367 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -87,6 +87,34 @@ jobs: - name: Run tests 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: runs-on: macos-latest env: diff --git a/package.json b/package.json index d12269f51..818435842 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,10 @@ "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: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: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:server": "node test/runner/server.js", "test:esm": "npm run pretest && npm run build:main && npm run test:unit -- --esm -h", diff --git a/test/runner/selenium/createDriver.js b/test/runner/selenium/createDriver.js index 095c12214..df1204763 100644 --- a/test/runner/selenium/createDriver.js +++ b/test/runner/selenium/createDriver.js @@ -2,6 +2,7 @@ import { Builder, Capabilities, logging } from "selenium-webdriver"; import Chrome from "selenium-webdriver/chrome.js"; import Edge from "selenium-webdriver/edge.js"; import Firefox from "selenium-webdriver/firefox.js"; +import IE from "selenium-webdriver/ie.js"; import { browserSupportsHeadless } from "../lib/getBrowserString.js"; // 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 } ) { const capabilities = Capabilities[ browserName ](); - const prefs = new logging.Preferences(); - prefs.setLevel( logging.Type.BROWSER, logging.Level.ALL ); - capabilities.setLoggingPrefs( prefs ); + + // Support: IE 11+ + // 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 ); @@ -49,6 +57,10 @@ export default async function createDriver( { browserName, headless, url, verbos 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 ) { chromeOptions.addArguments( "--headless=new" ); firefoxOptions.addArguments( "--headless" ); @@ -65,6 +77,7 @@ export default async function createDriver( { browserName, headless, url, verbos .setChromeOptions( chromeOptions ) .setFirefoxOptions( firefoxOptions ) .setEdgeOptions( edgeOptions ) + .setIeOptions( ieOptions ) .build(); if ( verbose ) { |