-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[js] Migrate javascript/atoms tests from Closure to QUnit #16855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The Closure testing framework is being phased out in favor of QUnit, which provides a more modern and maintainable test infrastructure. Later PRs will migrate the other usages of the Closure testing library. Several tests required DOM isolation via iframes because QUnit injects its own UI elements (#qunit, #qunit-fixture) that interfere with tests that count or query DOM elements. The Java test shim was updated to detect both Closure and QUnit test runners.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||||||||||||
titusfortner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the approach of keeping test and lib updates independent. Qunit does look like the right choice for this. Runner toggle looks good.
User description
The Closure testing framework is being phased out in favor of QUnit, which provides a more modern and maintainable test infrastructure. Later PRs will migrate the other usages of the Closure testing library.
Several tests required DOM isolation via iframes because QUnit injects its own UI elements (#qunit, #qunit-fixture) that interfere with tests that count or query DOM elements.
The Java test shim was updated to detect both Closure and QUnit test runners.
PR Type
Tests, Enhancement
Description
This PR migrates JavaScript atoms tests from the deprecated Closure testing framework to QUnit, providing a more modern and maintainable test infrastructure.
Key Changes:
Migrated 30+ test files from Closure's
goog.testing.jsunitto QUnit test frameworkConverted all test functions from Closure format (
function testName()) to QUnit format (QUnit.test())Replaced Closure assertions (
assertEquals,assertTrue,assertFalse) with QUnit equivalents (assert.strictEqual,assert.ok,assert.notOk)Implemented iframe-based test isolation for DOM-sensitive tests to prevent QUnit UI interference
Updated Java test harness (
ClosureTestStatement.java) to detect and support both Closure and QUnit test runnersCreated QUnit test runner adapter (
qunit_test_runner.js) for integration with Selenium's Java test infrastructureAdded QUnit 2.23.1 library to third-party dependencies with Bazel build configuration
Converted async tests to use QUnit's
assert.async()patternReplaced
ExpectedFailurespattern with inline skip logic for browser-specific testsUpdated test lifecycle hooks from Closure's
setUp/tearDownto QUnit'stestStart/testDoneModified helper functions throughout to accept QUnit's
assertparameterTest Files Migrated:
Core functionality:
click_test.html,mouse_test.html,keyboard_test.html,touchscreen_test.html,type_test.htmlDOM interaction:
locator_test.html,relative_locator_test.html,select_test.html,text_test.html,style_test.htmlElement state:
shown_test.html,enabled_test.html,overflow_test.html,scrolling_test.htmlHTML5 features:
database_test.html,storage_test.html,location_test.html,shadow_dom_test.htmlAnd many more test suites covering various atoms functionality
Diagram Walkthrough
File Walkthrough
2 files
ClosureTestStatement.java
Add dual test runner support for Closure and QUnit frameworksjava/test/org/openqa/selenium/javascript/ClosureTestStatement.java
frameworks
detectTestRunner()method that polls for test runnerinitialization
Queryenum toTestRunnerenum with separate implementationsfor Closure and QUnit
G_testRunnerandQUnitTestRunnerbetween tests
qunit_test_runner.js
Implement QUnit test runner adapter for Java harness integrationthird_party/js/qunit/qunit_test_runner.js
QUnitTestRunnerinterface onwindow.topwithisFinished(),isSuccess(), andgetReport()methodsdetails
information
18 files
useragent_test.js
Migrate useragent tests from Closure to QUnit frameworkjavascript/atoms/test/useragent_test.js
function testName()formatto QUnit's
QUnit.test()formatassertTrue,assertFalse) with QUnitassertions (
assert.ok,assert.notOk)assert.ok(true, 'Skipping: ...')text_util.js
Adapt text utility helpers for QUnit assertion stylejavascript/atoms/test/text_util.js
assertTextIs()helper function to accept QUnitassertobjectand
testNameparametersassertEquals()with QUnit'sassert.strictEqual()goog.testing.TestCasefor accessing current testname
locator_test.html
Migrate locator tests to QUnit with iframe isolationjavascript/atoms/test/locator_test.html
and QUnit UI elements
QUnit.test()format with QUnitassertions
interference with DOM tests
QUnit.begin,QUnit.testStart,QUnit.testDone) for setup/teardownseparate file
inject_test.html
Convert inject tests from Closure to QUnit frameworkjavascript/atoms/test/inject_test.html
(
assert.strictEqual,assert.ok,assert.throws, etc.)assert.async()pattern
goog.testing.jsunitdependency and added QUnit script includesclick_link_test.html
Migrate click link tests to QUnit with async supportjavascript/atoms/test/click_link_test.html
using
assert.async()assertparametergoog.testing.jsunitdependencyinstead of promises
response_test.html
Migrate response tests from Closure to QUnitjavascript/atoms/test/response_test.html
QUnit.test()formatassertEquals()andassertTrue()withassert.strictEqual()andassert.ok()select_test.html
Migrate select_test.html from Closure to QUnit testing frameworkjavascript/atoms/test/select_test.html
goog.testing.jsunitto QUnit test frameworksetUpPage()andsetUp()with QUnit'stestStart()hookQUnit.test()formatassertEquals,assertTrue, etc.) to QUnit style (assert.strictEqual,assert.ok, etc.)#qunit,#qunit-fixture) to HTML bodygoog.require('goog.testing.jsunit')and added QUnitscript/stylesheet references
mouse_test.html
Migrate mouse_test.html from Closure to QUnit testing frameworkjavascript/atoms/test/mouse_test.html
goog.testing.jsunitto QUnit test frameworksetUpPage()andsetUp()with QUnit'stestStart()hook andmodule-level initialization
QUnit.test()format withassertparameterassertEventshelper to accept
assertparameterassert.async()for promise-based testsshown_test.html
Migrate shown_test.html from Closure to QUnit testing frameworkjavascript/atoms/test/shown_test.html
goog.testing.jsunitto QUnit test frameworksetUp()andtearDown()with QUnit'stestDone()hookQUnit.test()formatExpectedFailurespattern with inline skip logic usingassert.ok(true, 'Skipping...')assert.ok,assert.notOk,assert.strictEqual)type_test.html
Migrate type_test.html from Closure to QUnit testing frameworkjavascript/atoms/test/type_test.html
goog.testing.jsunitto QUnit test frameworksetUp()andtearDown()with QUnit'stestStart()hookQUnit.test()formatrunTypingTesthelper function to acceptassertparameterExpectedFailureswith inline skip logic and converted asynctests to use
assert.async()text_test.html
Migrate text_test.html from Closure to QUnit testing frameworkjavascript/atoms/test/text_test.html
goog.testing.jsunitto QUnit test frameworkQUnit.test()formatassertContains,assertStartsWith,assertEndsWith) to acceptassertparameterExpectedFailurespattern with inline skip logicassert.strictEqual,assert.ok)style_test.html
Migrate style tests from Closure to QUnit frameworkjavascript/atoms/test/style_test.html
goog.testing.jsunitto QUnit test frameworkassertEquals,assertTrue,assertContainswith QUnit'sassert.strictEqual,assert.okQUnit.test()calls with descriptivenames
#qunit,#qunit-fixture) to HTML bodyassertColorFuzzyEqualshelper that acceptsassertparameter
click_test.html
Convert click action tests to QUnit test frameworkjavascript/atoms/test/click_test.html
setUp/tearDownwithQUnit.testStart/QUnit.testDonehooks(
assert.strictEqual,assert.deepEqual,assert.throws)assertparameter and use QUnitassertions
assert.strictEqualinstead ofcustom
assertEqualsrelative_locator_test.html
Migrate relative locator tests to QUnit with iframe isolationjavascript/atoms/test/relative_locator_test.html
QUnit.begin,QUnit.testStart,QUnit.testDonelifecycle hooks foriframe setup/teardown
QUnit.test()with proper assertionsassertEquals,assertTruewithassert.strictEqual,assert.okoverflow_test.html
Convert overflow state tests to QUnit frameworkjavascript/atoms/test/overflow_test.html
tearDownwithQUnit.testDonehook(
assert.strictEqual,assert.notOk)QUnit.test()calls with descriptive namesassert.ok(true, 'Skipping...')for unsupported browsers
touchscreen_test.html
Migrate touchscreen interaction tests to QUnit frameworkjavascript/atoms/test/touchscreen_test.html
setUpwithQUnit.testStartand addedQUnit.beginfor pagesetup
QUnit.test()with QUnit assertionsassertEvents,verifyTapEvents) to acceptassertparameterassert.ok,assert.strictEqual,assert.deepEqual)assert.async()for scroll testingscrolling_test.html
Convert scrolling behavior tests to QUnit frameworkjavascript/atoms/test/scrolling_test.html
setUp/tearDownwithQUnit.testStart/QUnit.testDonehooksgoog.testing.ExpectedFailuresin favor of conditional testskipping
assert.strictEqual,assert.notStrictEqual,assert.ok)QUnit.test()with descriptive namestext_table_test.html
Migrate table text extraction tests to QUnit frameworkjavascript/atoms/test/text_table_test.html
setUp/tearDowntoQUnit.testStart/QUnit.testDonehooksassertTextIshelper to acceptassertparameterQUnit.test()with descriptive testnames
goog.testing.ExpectedFailuresfor browser-specific failurehandling
2 files
test_suite.bzl
Include QUnit library in test suite dependenciesjavascript/private/test_suite.bzl
//third_party/js/qunitto the default data dependencies forclosure test suites
BUILD.bazel
Add Bazel build configuration for QUnit librarythird_party/js/qunit/BUILD.bazel
filegrouptarget containing QUnit CSS, JS, and test runnerfiles
JavaScript subpackages
1 files
VERSION
Document QUnit version 2.23.1third_party/js/qunit/VERSION
42 files