2016-05-10 09:12:28 +00:00
|
|
|
/* eslint no-multi-str: "off" */
|
2019-04-29 20:56:09 +00:00
|
|
|
"use strict";
|
|
|
|
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
var parentUrl = window.location.protocol + "//" + window.location.host,
|
2018-09-07 14:14:01 +00:00
|
|
|
|
|
|
|
// baseURL is intentionally set to "data/" instead of "".
|
|
|
|
// This is not just for convenience (since most files are in data/)
|
|
|
|
// but also to ensure that urls without prefix fail.
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
baseURL = parentUrl + "/test/data/",
|
2013-09-03 13:55:32 +00:00
|
|
|
supportjQuery = this.jQuery,
|
2015-08-16 06:59:58 +00:00
|
|
|
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
// NOTE: keep it in sync with build/tasks/lib/slim-exclude.js
|
2023-09-18 16:39:00 +00:00
|
|
|
excludedFromSlim = [
|
|
|
|
"ajax",
|
|
|
|
"callbacks",
|
|
|
|
"deferred",
|
|
|
|
"effects",
|
|
|
|
"queue"
|
2022-06-28 10:39:01 +00:00
|
|
|
];
|
2011-04-17 03:35:18 +00:00
|
|
|
|
2023-09-18 16:39:00 +00:00
|
|
|
// see RFC 2606
|
|
|
|
this.externalHost = "example.com";
|
2013-04-09 15:45:09 +00:00
|
|
|
this.hasPHP = true;
|
|
|
|
this.isLocal = window.location.protocol === "file:";
|
|
|
|
|
2013-09-03 13:55:32 +00:00
|
|
|
// Setup global variables before loading jQuery for testing .noConflict()
|
|
|
|
supportjQuery.noConflict( true );
|
2016-05-10 09:12:28 +00:00
|
|
|
window.originaljQuery = this.jQuery = undefined;
|
|
|
|
window.original$ = this.$ = "replaced";
|
2012-11-01 04:40:27 +00:00
|
|
|
|
2009-09-29 18:11:10 +00:00
|
|
|
/**
|
2012-05-29 16:40:13 +00:00
|
|
|
* Returns an array of elements with the given IDs
|
2014-02-18 16:13:48 +00:00
|
|
|
* @example q( "main", "foo", "bar" )
|
2009-09-29 18:11:10 +00:00
|
|
|
* @result [<div id="main">, <span id="foo">, <input id="bar">]
|
|
|
|
*/
|
2013-04-09 15:45:09 +00:00
|
|
|
this.q = function() {
|
2012-05-28 16:43:41 +00:00
|
|
|
var r = [],
|
|
|
|
i = 0;
|
2009-09-29 18:11:10 +00:00
|
|
|
|
2012-05-28 16:43:41 +00:00
|
|
|
for ( ; i < arguments.length; i++ ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
r.push( document.getElementById( arguments[ i ] ) );
|
2009-09-29 18:11:10 +00:00
|
|
|
}
|
|
|
|
return r;
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2009-09-29 18:11:10 +00:00
|
|
|
|
|
|
|
/**
|
2012-05-29 16:40:13 +00:00
|
|
|
* Asserts that a select matches the given IDs
|
2016-03-05 09:48:52 +00:00
|
|
|
* @param {String} message - Assertion name
|
2019-07-29 19:14:46 +00:00
|
|
|
* @param {String} selector - jQuery selector
|
2016-03-05 09:48:52 +00:00
|
|
|
* @param {String} expectedIds - Array of ids to construct what is expected
|
|
|
|
* @param {(String|Node)=document} context - Selector context
|
|
|
|
* @example match("Check for something", "p", ["foo", "bar"]);
|
2009-09-29 18:11:10 +00:00
|
|
|
*/
|
2019-02-18 18:02:38 +00:00
|
|
|
function match( message, selector, expectedIds, context, assert ) {
|
2019-06-26 19:39:10 +00:00
|
|
|
var elems = jQuery( selector, context ).get();
|
2009-09-29 18:11:10 +00:00
|
|
|
|
2019-06-26 19:39:10 +00:00
|
|
|
assert.deepEqual( elems, q.apply( q, expectedIds ), message + " (" + selector + ")" );
|
2016-03-05 09:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asserts that a select matches the given IDs.
|
|
|
|
* The select is not bound by a context.
|
|
|
|
* @param {String} message - Assertion name
|
2019-07-29 19:14:46 +00:00
|
|
|
* @param {String} selector - jQuery selector
|
2016-03-05 09:48:52 +00:00
|
|
|
* @param {String} expectedIds - Array of ids to construct what is expected
|
|
|
|
* @example t("Check for something", "p", ["foo", "bar"]);
|
|
|
|
*/
|
|
|
|
QUnit.assert.t = function( message, selector, expectedIds ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
match( message, selector, expectedIds, undefined, QUnit.assert );
|
2016-03-05 09:48:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asserts that a select matches the given IDs.
|
|
|
|
* The select is performed within the `#qunit-fixture` context.
|
|
|
|
* @param {String} message - Assertion name
|
2019-07-29 19:14:46 +00:00
|
|
|
* @param {String} selector - jQuery selector
|
2016-03-05 09:48:52 +00:00
|
|
|
* @param {String} expectedIds - Array of ids to construct what is expected
|
|
|
|
* @example selectInFixture("Check for something", "p", ["foo", "bar"]);
|
|
|
|
*/
|
|
|
|
QUnit.assert.selectInFixture = function( message, selector, expectedIds ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
match( message, selector, expectedIds, "#qunit-fixture", QUnit.assert );
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2009-09-29 18:11:10 +00:00
|
|
|
|
2013-04-09 15:45:09 +00:00
|
|
|
this.createDashboardXML = function() {
|
2016-05-10 09:12:28 +00:00
|
|
|
var string = "<?xml version='1.0' encoding='UTF-8'?> \
|
2012-04-15 21:41:54 +00:00
|
|
|
<dashboard> \
|
2016-05-10 09:12:28 +00:00
|
|
|
<locations class='foo'> \
|
|
|
|
<location for='bar' checked='different'> \
|
|
|
|
<infowindowtab normal='ab' mixedCase='yes'> \
|
|
|
|
<tab title='Location'><![CDATA[blabla]]></tab> \
|
|
|
|
<tab title='Users'><![CDATA[blublu]]></tab> \
|
2012-04-15 21:41:54 +00:00
|
|
|
</infowindowtab> \
|
|
|
|
</location> \
|
|
|
|
</locations> \
|
2016-05-10 09:12:28 +00:00
|
|
|
</dashboard>";
|
2012-04-15 21:41:54 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
return jQuery.parseXML( string );
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2012-04-15 21:41:54 +00:00
|
|
|
|
2019-06-26 19:39:10 +00:00
|
|
|
this.createWithFriesXML = function() {
|
|
|
|
var string = "<?xml version='1.0' encoding='UTF-8'?> \
|
|
|
|
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' \
|
|
|
|
xmlns:xsd='http://www.w3.org/2001/XMLSchema' \
|
|
|
|
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> \
|
|
|
|
<soap:Body> \
|
|
|
|
<jsconf xmlns='http://www.example.com/ns1'> \
|
|
|
|
<response xmlns:ab='http://www.example.com/ns2'> \
|
|
|
|
<meta> \
|
|
|
|
<component id='seite1' class='component'> \
|
|
|
|
<properties xmlns:cd='http://www.example.com/ns3'> \
|
|
|
|
<property name='prop1'> \
|
|
|
|
<thing /> \
|
|
|
|
<value>1</value> \
|
|
|
|
</property> \
|
|
|
|
<property name='prop2'> \
|
|
|
|
<thing att='something' /> \
|
|
|
|
</property> \
|
|
|
|
<foo_bar>foo</foo_bar> \
|
|
|
|
</properties> \
|
|
|
|
</component> \
|
|
|
|
</meta> \
|
|
|
|
</response> \
|
|
|
|
</jsconf> \
|
|
|
|
</soap:Body> \
|
|
|
|
</soap:Envelope>";
|
|
|
|
|
|
|
|
return jQuery.parseXML( string );
|
|
|
|
};
|
|
|
|
|
2013-04-09 15:45:09 +00:00
|
|
|
this.createXMLFragment = function() {
|
2019-04-29 20:56:09 +00:00
|
|
|
var frag,
|
2012-10-15 18:20:36 +00:00
|
|
|
xml = document.implementation.createDocument( "", "", null );
|
|
|
|
|
|
|
|
if ( xml ) {
|
2014-02-18 16:13:48 +00:00
|
|
|
frag = xml.createElement( "data" );
|
2012-10-15 18:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return frag;
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2012-10-15 18:20:36 +00:00
|
|
|
|
2023-09-19 22:54:40 +00:00
|
|
|
window.fireNative = function( node, type ) {
|
|
|
|
var event = document.createEvent( "HTMLEvents" );
|
|
|
|
|
|
|
|
event.initEvent( type, true, true );
|
|
|
|
node.dispatchEvent( event );
|
|
|
|
};
|
2011-10-28 18:17:14 +00:00
|
|
|
|
2009-09-29 18:11:10 +00:00
|
|
|
/**
|
2012-05-29 16:40:13 +00:00
|
|
|
* Add random number to url to stop caching
|
2009-09-29 18:11:10 +00:00
|
|
|
*
|
2017-08-01 16:52:45 +00:00
|
|
|
* Also prefixes with baseURL automatically.
|
2009-09-29 18:11:10 +00:00
|
|
|
*
|
2017-08-01 16:52:45 +00:00
|
|
|
* @example url("index.html")
|
|
|
|
* @result "data/index.html?10538358428943"
|
|
|
|
*
|
|
|
|
* @example url("mock.php?foo=bar")
|
|
|
|
* @result "data/mock.php?foo=bar&10538358345554"
|
2009-09-29 18:11:10 +00:00
|
|
|
*/
|
2012-05-29 16:40:13 +00:00
|
|
|
function url( value ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
return baseURL + value + ( /\?/.test( value ) ? "&" : "?" ) +
|
2014-02-18 15:49:24 +00:00
|
|
|
new Date().getTime() + "" + parseInt( Math.random() * 100000, 10 );
|
2009-09-29 18:11:10 +00:00
|
|
|
}
|
2011-01-09 21:58:47 +00:00
|
|
|
|
2012-11-26 02:31:19 +00:00
|
|
|
// Ajax testing helper
|
2023-02-01 12:48:35 +00:00
|
|
|
this.ajaxTest = function( title, expect, options, wrapper ) {
|
|
|
|
if ( !wrapper ) {
|
|
|
|
wrapper = QUnit.test;
|
|
|
|
}
|
|
|
|
wrapper.call( QUnit, title, function( assert ) {
|
2019-02-18 18:02:38 +00:00
|
|
|
assert.expect( expect );
|
2015-08-16 03:45:28 +00:00
|
|
|
var requestOptions;
|
|
|
|
|
2017-12-13 06:43:30 +00:00
|
|
|
if ( typeof options === "function" ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
options = options( assert );
|
|
|
|
}
|
|
|
|
options = options || [];
|
|
|
|
requestOptions = options.requests || options.request || options;
|
2016-08-14 10:54:16 +00:00
|
|
|
if ( !Array.isArray( requestOptions ) ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
requestOptions = [ requestOptions ];
|
|
|
|
}
|
|
|
|
|
|
|
|
var done = assert.async();
|
|
|
|
|
2012-11-26 10:49:20 +00:00
|
|
|
if ( options.setup ) {
|
|
|
|
options.setup();
|
2012-11-26 02:31:19 +00:00
|
|
|
}
|
2012-12-03 04:32:16 +00:00
|
|
|
|
|
|
|
var completed = false,
|
2012-12-03 16:32:19 +00:00
|
|
|
remaining = requestOptions.length,
|
2012-12-03 04:32:16 +00:00
|
|
|
complete = function() {
|
2012-12-03 16:32:19 +00:00
|
|
|
if ( !completed && --remaining === 0 ) {
|
|
|
|
completed = true;
|
|
|
|
delete ajaxTest.abort;
|
|
|
|
if ( options.teardown ) {
|
|
|
|
options.teardown();
|
|
|
|
}
|
2015-08-16 03:45:28 +00:00
|
|
|
|
|
|
|
// Make sure all events will be called before done()
|
2015-08-16 06:59:58 +00:00
|
|
|
setTimeout( done );
|
2012-11-26 10:49:20 +00:00
|
|
|
}
|
|
|
|
},
|
2012-12-03 16:32:19 +00:00
|
|
|
requests = jQuery.map( requestOptions, function( options ) {
|
2012-12-03 04:32:16 +00:00
|
|
|
var request = ( options.create || jQuery.ajax )( options ),
|
|
|
|
callIfDefined = function( deferType, optionType ) {
|
|
|
|
var handler = options[ deferType ] || !!options[ optionType ];
|
2012-12-03 16:32:19 +00:00
|
|
|
return function( _, status ) {
|
|
|
|
if ( !completed ) {
|
|
|
|
if ( !handler ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.ok( false, "unexpected " + status );
|
2017-12-13 06:43:30 +00:00
|
|
|
} else if ( typeof handler === "function" ) {
|
2012-12-03 04:32:16 +00:00
|
|
|
handler.apply( this, arguments );
|
|
|
|
}
|
2012-12-03 16:32:19 +00:00
|
|
|
}
|
|
|
|
};
|
2012-12-03 04:32:16 +00:00
|
|
|
};
|
|
|
|
|
2012-11-26 10:49:20 +00:00
|
|
|
if ( options.afterSend ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
options.afterSend( request, assert );
|
2012-11-26 10:49:20 +00:00
|
|
|
}
|
2012-12-03 04:32:16 +00:00
|
|
|
|
2012-12-03 05:49:40 +00:00
|
|
|
return request
|
|
|
|
.done( callIfDefined( "done", "success" ) )
|
2012-12-03 16:32:19 +00:00
|
|
|
.fail( callIfDefined( "fail", "error" ) )
|
|
|
|
.always( complete );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-12-03 04:32:16 +00:00
|
|
|
|
2012-12-03 16:32:19 +00:00
|
|
|
ajaxTest.abort = function( reason ) {
|
|
|
|
if ( !completed ) {
|
|
|
|
completed = true;
|
|
|
|
delete ajaxTest.abort;
|
2015-09-08 00:26:29 +00:00
|
|
|
assert.ok( false, "aborted " + reason );
|
2023-09-18 16:39:00 +00:00
|
|
|
jQuery.each( requests, function( _i, request ) {
|
2012-12-03 16:32:19 +00:00
|
|
|
request.abort();
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2012-12-03 16:32:19 +00:00
|
|
|
}
|
|
|
|
};
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2012-11-26 02:31:19 +00:00
|
|
|
|
2023-11-06 23:35:52 +00:00
|
|
|
this.testIframe = function( title, fileName, func, wrapper, iframeStyles ) {
|
2017-04-25 20:22:35 +00:00
|
|
|
if ( !wrapper ) {
|
|
|
|
wrapper = QUnit.test;
|
|
|
|
}
|
|
|
|
wrapper.call( QUnit, title, function( assert ) {
|
2017-04-25 19:39:41 +00:00
|
|
|
var done = assert.async(),
|
2020-03-16 20:49:29 +00:00
|
|
|
$iframe = supportjQuery( "<iframe></iframe>" )
|
2017-04-29 06:00:12 +00:00
|
|
|
.css( { position: "absolute", top: "0", left: "-600px", width: "500px" } )
|
2017-08-01 16:52:45 +00:00
|
|
|
.attr( { id: "qunit-fixture-iframe", src: url( fileName ) } );
|
2013-04-09 15:45:09 +00:00
|
|
|
|
2023-11-06 23:35:52 +00:00
|
|
|
// Add other iframe styles
|
|
|
|
if ( iframeStyles ) {
|
|
|
|
$iframe.css( iframeStyles );
|
|
|
|
}
|
|
|
|
|
2017-04-25 01:44:51 +00:00
|
|
|
// Test iframes are expected to invoke this via startIframeTest (cf. iframeTest.js)
|
2013-04-09 15:45:09 +00:00
|
|
|
window.iframeCallback = function() {
|
2015-08-16 03:45:28 +00:00
|
|
|
var args = Array.prototype.slice.call( arguments );
|
|
|
|
|
2016-04-10 19:42:44 +00:00
|
|
|
args.unshift( assert );
|
2014-02-18 16:13:48 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
setTimeout( function() {
|
2020-02-10 18:17:22 +00:00
|
|
|
var result;
|
|
|
|
|
2014-02-18 16:13:48 +00:00
|
|
|
this.iframeCallback = undefined;
|
|
|
|
|
2020-02-10 18:17:22 +00:00
|
|
|
result = func.apply( this, args );
|
|
|
|
|
|
|
|
function finish() {
|
|
|
|
func = function() {};
|
|
|
|
$iframe.remove();
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for promises returned by `func`.
|
|
|
|
if ( result && result.then ) {
|
|
|
|
result.then( finish );
|
|
|
|
} else {
|
|
|
|
finish();
|
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2017-04-25 19:39:41 +00:00
|
|
|
|
|
|
|
// Attach iframe to the body for visibility-dependent code
|
|
|
|
// It will be removed by either the above code, or the testDone callback in testrunner.js
|
2017-04-25 20:32:40 +00:00
|
|
|
$iframe.prependTo( document.body );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2014-02-18 16:13:48 +00:00
|
|
|
this.iframeCallback = undefined;
|
2013-09-06 20:23:20 +00:00
|
|
|
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
QUnit.config.autostart = false;
|
2016-04-03 22:07:14 +00:00
|
|
|
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
// Leverage QUnit URL parsing to detect "basic" testing mode
|
2017-08-01 16:52:45 +00:00
|
|
|
QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic";
|
2013-09-06 20:23:20 +00:00
|
|
|
|
2022-06-28 10:39:01 +00:00
|
|
|
// Returns whether a particular module like "ajax" or "deprecated"
|
|
|
|
// is included in the current jQuery build; it handles the slim build
|
|
|
|
// as well. The util was created so that we don't treat presence of
|
|
|
|
// particular APIs to decide whether to run a test as then if we
|
|
|
|
// accidentally remove an API, the tests would still not fail.
|
|
|
|
this.includesModule = function( moduleName ) {
|
|
|
|
|
|
|
|
var excludedModulesPart, excludedModules;
|
|
|
|
|
2023-09-18 16:39:00 +00:00
|
|
|
// A short-cut for the slim build, e.g. "4.0.0-pre+slim"
|
|
|
|
if ( jQuery.fn.jquery.indexOf( "+slim" ) > -1 ) {
|
2022-06-28 10:39:01 +00:00
|
|
|
|
|
|
|
// The module is included if it does NOT exist on the list
|
|
|
|
// of modules excluded in the slim build
|
2023-09-18 16:39:00 +00:00
|
|
|
return excludedFromSlim.indexOf( moduleName ) === -1;
|
2022-06-28 10:39:01 +00:00
|
|
|
}
|
|
|
|
|
2023-09-18 16:39:00 +00:00
|
|
|
// example version for `npm run build -- -e deprecated`:
|
|
|
|
// "v4.0.0-pre+14dc9347 -deprecated,-deprecated/ajax-event-alias,-deprecated/event"
|
2022-06-28 10:39:01 +00:00
|
|
|
excludedModulesPart = jQuery.fn.jquery
|
|
|
|
|
|
|
|
// Take the flags out of the version string.
|
|
|
|
// Example: "-deprecated,-deprecated/ajax-event-alias,-deprecated/event"
|
|
|
|
.split( " " )[ 1 ];
|
|
|
|
|
|
|
|
if ( !excludedModulesPart ) {
|
|
|
|
|
|
|
|
// No build part => the full build where everything is included.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
excludedModules = excludedModulesPart
|
|
|
|
|
|
|
|
// Turn to an array.
|
|
|
|
// Example: [ "-deprecated", "-deprecated/ajax-event-alias", "-deprecated/event" ]
|
|
|
|
.split( "," )
|
|
|
|
|
|
|
|
// Remove the leading "-".
|
|
|
|
// Example: [ "deprecated", "deprecated/ajax-event-alias", "deprecated/event" ]
|
|
|
|
.map( function( moduleName ) {
|
|
|
|
return moduleName.slice( 1 );
|
|
|
|
} )
|
|
|
|
|
|
|
|
// Filter out deep names - ones that contain a slash.
|
|
|
|
// Example: [ "deprecated" ]
|
|
|
|
.filter( function( moduleName ) {
|
|
|
|
return moduleName.indexOf( "/" ) === -1;
|
|
|
|
} );
|
|
|
|
|
|
|
|
return excludedModules.indexOf( moduleName ) === -1;
|
|
|
|
};
|
|
|
|
|
2017-08-01 16:52:45 +00:00
|
|
|
this.loadTests = function() {
|
2018-01-16 20:18:32 +00:00
|
|
|
|
2019-12-09 19:00:44 +00:00
|
|
|
// QUnit.config is populated from QUnit.urlParams but only at the beginning
|
|
|
|
// of the test run. We need to read both.
|
2023-06-27 16:23:58 +00:00
|
|
|
var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules;
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
var jsdom = QUnit.config.jsdom || QUnit.urlParams.jsdom;
|
|
|
|
|
|
|
|
if ( jsdom ) {
|
|
|
|
|
|
|
|
// JSDOM doesn't implement scrollTo
|
|
|
|
QUnit.config.scrolltop = false;
|
|
|
|
}
|
2019-12-09 19:00:44 +00:00
|
|
|
|
|
|
|
// Directly load tests that need evaluation before DOMContentLoaded.
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
if ( !jsdom && ( !esmodules || document.readyState === "loading" ) ) {
|
|
|
|
document.write( "<script src='" + parentUrl + "/test/unit/ready.js'><\x2Fscript>" );
|
2018-09-07 14:14:01 +00:00
|
|
|
} else {
|
|
|
|
QUnit.module( "ready", function() {
|
2019-12-09 19:00:44 +00:00
|
|
|
QUnit.skip( "jQuery ready tests skipped in async mode", function() {} );
|
2018-09-07 14:14:01 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:11:04 +00:00
|
|
|
// Get testSubproject from testrunner first
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
require( [ parentUrl + "/test/data/testrunner.js" ], function() {
|
2022-11-21 22:23:39 +00:00
|
|
|
|
|
|
|
// Says whether jQuery positional selector extensions are supported.
|
|
|
|
// A full selector engine is required to support them as they need to
|
|
|
|
// be evaluated left-to-right. Remove that property when support for
|
|
|
|
// positional selectors is dropped.
|
|
|
|
QUnit.jQuerySelectorsPos = includesModule( "selector" );
|
|
|
|
|
|
|
|
// Says whether jQuery selector extensions are supported. Change that
|
|
|
|
// to `false` if your custom jQuery versions relies more on native qSA.
|
|
|
|
// This doesn't include support for positional selectors (see above).
|
|
|
|
QUnit.jQuerySelectors = includesModule( "selector" );
|
|
|
|
|
2015-09-08 19:56:08 +00:00
|
|
|
var i = 0,
|
|
|
|
tests = [
|
2023-09-18 16:39:00 +00:00
|
|
|
|
2019-04-29 20:56:09 +00:00
|
|
|
// A special module with basic tests, meant for not fully
|
|
|
|
// supported environments like jsdom. We run it everywhere,
|
|
|
|
// though, to make sure tests are not broken.
|
2015-09-08 19:56:08 +00:00
|
|
|
"unit/basic.js",
|
|
|
|
|
2015-09-08 16:36:02 +00:00
|
|
|
"unit/core.js",
|
|
|
|
"unit/callbacks.js",
|
|
|
|
"unit/deferred.js",
|
2015-10-01 20:03:10 +00:00
|
|
|
"unit/deprecated.js",
|
2015-09-08 16:36:02 +00:00
|
|
|
"unit/support.js",
|
|
|
|
"unit/data.js",
|
|
|
|
"unit/queue.js",
|
|
|
|
"unit/attributes.js",
|
|
|
|
"unit/event.js",
|
|
|
|
"unit/selector.js",
|
|
|
|
"unit/traversing.js",
|
|
|
|
"unit/manipulation.js",
|
|
|
|
"unit/wrap.js",
|
|
|
|
"unit/css.js",
|
|
|
|
"unit/serialize.js",
|
|
|
|
"unit/ajax.js",
|
|
|
|
"unit/effects.js",
|
|
|
|
"unit/offset.js",
|
|
|
|
"unit/dimensions.js",
|
|
|
|
"unit/animation.js",
|
|
|
|
"unit/tween.js"
|
2015-09-08 19:56:08 +00:00
|
|
|
];
|
2013-09-06 21:11:04 +00:00
|
|
|
|
|
|
|
// Ensure load order (to preserve test numbers)
|
2015-08-16 06:59:58 +00:00
|
|
|
( function loadDep() {
|
2015-09-08 19:56:08 +00:00
|
|
|
var dep = tests[ i++ ];
|
2014-02-18 15:49:24 +00:00
|
|
|
|
2013-09-06 21:11:04 +00:00
|
|
|
if ( dep ) {
|
2016-04-03 22:07:14 +00:00
|
|
|
if ( !QUnit.basicTests || i === 1 ) {
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
require( [ parentUrl + "/test/" + dep ], loadDep );
|
2015-09-08 19:56:08 +00:00
|
|
|
|
|
|
|
// When running basic tests, replace other modules with dummies to avoid overloading
|
|
|
|
// impaired clients.
|
|
|
|
} else {
|
|
|
|
QUnit.module( dep.replace( /^.*\/|\.js$/g, "" ) );
|
|
|
|
loadDep();
|
|
|
|
}
|
2013-11-14 15:17:18 +00:00
|
|
|
|
2014-02-18 15:49:24 +00:00
|
|
|
} else {
|
2013-09-06 21:11:04 +00:00
|
|
|
|
2014-02-18 15:49:24 +00:00
|
|
|
/**
|
|
|
|
* Run in noConflict mode
|
|
|
|
*/
|
2016-08-15 15:41:11 +00:00
|
|
|
jQuery.noConflict();
|
2013-09-06 20:23:20 +00:00
|
|
|
|
Tests: migrate testing infrastructure to minimal dependencies
This is a complete rework of our testing infrastructure. The main goal is to modernize and drop deprecated or undermaintained dependencies (specifically, grunt, karma, and testswarm). We've achieved that by limiting our dependency list to ones that are unlikely to drop support any time soon. The new dependency list includes:
- `qunit` (our trusty unit testing library)
- `selenium-webdriver` (for spinning up local browsers)
- `express` (for starting a test server and adding middleware)
- express middleware includes uses of `body-parser` and `raw-body`
- `yargs` (for constructing a CLI with pretty help text)
- BrowserStack (for running each of our QUnit modules separately in all of our supported browsers)
- `browserstack-local` (for opening a local tunnel. This is the same package still currently used in the new Browserstack SDK)
- We are not using any other BrowserStack library. The newest BrowserStack SDK does not fit our needs (and isn't open source). Existing libraries, such as `node-browserstack` or `browserstack-runner`, either do not quite fit our needs, are under-maintained and out-of-date, or are not robust enough to meet all of our requirements. We instead call the [BrowserStack REST API](https://github.com/browserstack/api) directly.
## BrowserStack Runner
- automatically retries individual modules in case of test failure(s)
- automatically attempts to re-establish broken tunnels
- automatically refreshes the page in case a test run has stalled
- runs all browsers concurrently and uses as many sessions as are available under the BrowserStack plan. It will wait for available sessions if there are none.
- supports filtering the available list of browsers by browser name, browser version, device, OS, and OS version (see `npm run test:unit -- --list-browsers` for more info). It will retrieve the latest matching browser available if any of those parameters are not specified.
- cleans up after itself (closes the local tunnel, stops the test server, etc.)
- Requires `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables.
## Selenium Runner
- supports running any local browser as long as the driver is installed, including support for headless mode in Chrome, FF, and Edge
- supports running `basic` tests on the latest [jsdom](https://github.com/jsdom/jsdom#readme), which can be seen in action in this PR (see `test:browserless`)
- Node tests will run as before in PRs and all non-dependabot branches, but now includes tests on real Safari in a GH actions macos image instead of playwright-webkit.
- can run multiple browsers and multiple modules concurrently
Other notes:
- Stale dependencies have been removed and all remaining dependencies have been upgraded with a few exceptions:
- `sinon`: stopped supporting IE in version 10. But, `sinon` has been updated to 9.x.
- `husky`: latest does not support Node 10 and runs on `npm install`. Needed for now until git builds are migrated to GitHub Actions.
- `rollup`: latest does not support Node 10. Needed for now until git builds are migrated to GitHub Actions.
- BrowserStack tests are set to run on each `main` branch commit
- `debug` mode leaves Selenium browsers open whether they pass or fail and leaves browsers with test failures open on BrowserStack. The latter is to avoid leaving open too many sessions.
- This PR includes a workflow to dispatch BrowserStack runs on-demand
- The Node version used for most workflow tests has been upgraded to 20.x
- updated supportjQuery to 3.7.1
Run `npm run test:unit -- --help` for CLI documentation
Close gh-5418
2024-02-26 14:42:10 +00:00
|
|
|
QUnit.start();
|
2013-09-06 21:11:04 +00:00
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} )();
|
|
|
|
} );
|
2013-09-06 20:23:20 +00:00
|
|
|
};
|