Commit Graph

159 Commits

Author SHA1 Message Date
Timmy Willison
95a4c94b81
Tests: reuse browser workers in BrowserStack tests (#5428)
- reuse BrowserStack workers.
- add support for "latest" and "latest-1" in browser version filters
- add support for specifying non-final browser versions, such as beta versions
- more accurate eslint for files in test/runner
- switched `--no-isolate` command flag to `--isolate`. Now that browser instances are shared, it made more sense to me to default to no isolation unless specified. This turned out to be cleaner because the only place we isolate is in browserstack.yml.
- fixed an issue with retries where it wasn't always waiting for the retried test run
- enable strict mode in test yargs command
2024-03-05 14:44:01 -05:00
Timmy Willison
dfc693ea25
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 09:42:10 -05:00
Michał Gołębiowski-Owczarek
5701957b72
Build: Drop individual AMD modules
With this change, jQuery build no longer generates the `amd` directory with
AMD modules transpiled from source `src` ECMAScript Modules. To use individual
jQuery modules from source, ESM is now required.

Note that this DOES NOT affect the main `"jquery"` AMD module defined by built
jQuery files; those remain supported.

Closes gh-5276
2023-06-27 18:23:58 +02:00
Michał Gołębiowski-Owczarek
a684e6ba83
Build: Restore the external directory
In gh-4466, we removed the `external` directory in favor of loading some files
directly from `node_modules`. This works fine locally but when deploying code
for tests, this makes it impossible to not deploy `node_modules` as well. To
avoid the issue, this change restores usage of the `external` directory.

One change is that we no longer commit this directory to the repository, its
only purpose is to have clear isolation from `node_modules`.

Ref gh-4466
Closess gh-4865
2021-03-24 23:36:25 +01:00
Necmettin Karakaya
fa0058af42
Build: Use the US spelling of "favor"
Closes gh-4752
2020-07-22 16:12:54 +02:00
Michał Gołębiowski-Owczarek
341c6d1b5a
Build: Make Karma work in ES modules mode
Also, run such a suite in CI to make sure modules are working as expected
when used directly.

Closes gh-4550
2019-12-16 19:33:49 +01:00
Michał Gołębiowski-Owczarek
f37c2e51f3
Build: Auto-convert sources to AMD
jQuery source has been migrated in gh-4541 from AMD to ES modules. To maintain
support for consumers of our AMD modules, this commits adds a task transpiling
the ES modules sources in `src/` to AMD in `amd/`.

A "Load with AMD" checkbox was also restored to the QUnit setup. Note that,
contrary to jQuery 3.x, AMD files need to be generated via `grunt amd` or
`grunt` as sources are not authored in ECMAScript modules. To achieve a similar
no-compile experience during jQuery 4.x testing, use the new "Load as modules"
checkbox which works in all supported browsers except for IE & Edge (the
legacy, EdgeHTML-based one).

Ref gh-4541
Closes gh-4554
2019-12-09 20:00:44 +01:00
Michał Gołębiowski-Owczarek
d0ce00cdfa
Core: Migrate from AMD to ES modules 🎉
Migrate all source AMD modules to ECMAScript modules. The final bundle
is compiled by a custom build process that uses Rollup under the hood.

Test files themselves are still loaded via RequireJS as that has to work in
IE 11.

Tests can now be run in "Load as modules" mode which replaces the previous
"Load with AMD" option. That option of running tests doesn't work in IE
and Edge as it requires support for dynamic imports.

Some of the changes required by the migration:
* check `typeof` of `noGlobal` instead of using the variable directly
  as it's not available when modules are used
* change the nonce module to be an object as ECMASscript module exports
  are immutable
* remove some unused exports
* import `./core/parseHTML.js` directly in `jquery.js` so that it's not
  being cut out when the `ajax` module is excluded in a custom compilation

Closes gh-4541
2019-11-18 21:15:03 +01:00
Michał Gołębiowski-Owczarek
d7e64190ef
Build: Remove the external directory, read from node_modules directly
Now that Sizzle is gone & we use npm, we can read from node_modules directly
and skip the setup that copies some files to the external directory.

Closes gh-4466
2019-08-26 18:53:54 +02:00
Michał Gołębiowski-Owczarek
6ced2639b5
Build: Update QUnit from 1.23.1 to 2.9.2
Closes gh-4307
2019-03-04 20:10:21 +01:00
Timo Tijhof
ecd8ddea33
Tests: Add support for running unit tests via grunt with karma
- Update QUnit to 1.23.1
- Remove unused dl#dl from test/index.html
- Remove unused map#imgmap from test/index.html
- Ensure all urls to data use baseURI
- Add the 'grunt karma:main' task
  - customContextFile & customDebugFile
- Add 'npm run jenkins' script

Close gh-3744
Fixes gh-1999
2017-12-18 12:27:38 -05:00
Richard Gibson
deba37e53d Tests: Simulate events when CI hinders use of native ones
Ref gh-3732
2017-07-20 13:16:04 -04:00
Michał Gołębiowski
67c96a59f5 Build: Update npm deps, fix Sinon npmcopy config
All deps were updated except:
 * jsdom - tests using a Symbol polyfill are hacky and break with newer jsdom;
   we need to re-do them properly first
 * qunitjs - versions 1.19.0 & 1.20.0 introduce race conditions to the tests,
   making the fail randomly

Those two packages will be updated once issues related to them get resolved.

Fixes gh-2877
2016-01-27 12:54:39 +01:00
Henry Wong
1712457fbc Tests: fixed grammar in comment
Close gh-2757
2016-01-13 13:20:20 -05:00
Thomas Tortorini
3dd3d1357d Effects: Finish should call progress
Fixes gh-2283
Closes gh-2292
2015-09-08 02:40:54 +02:00
Corey Frang
cdaed15c7e Effects: Add tests for jQuery.Tween 2015-06-26 20:05:25 -04:00
Gabriel Schulhof
7475d5debe Event: Remove fake originalEvent from jQuery.Event.simulate
Fixes gh-2300
Closes gh-2303
2015-05-29 19:56:06 +03:00
Richard Gibson
555a50d340 Deferred: Backwards-compatible standards interoperability
Fixes gh-1722
Closes gh-1996
2015-03-20 02:00:17 -04:00
Oleg Gaidarenko
8356281bed Tests: make top of the HTML suite compliant with style guide
See http://contribute.jquery.org/style-guide/html/

Closes gh-2098
2015-02-19 11:30:57 +03:00
Scott González
c5d9d88dce Build: Move all external libraries to external directory
Closes gh-1593
2014-06-24 10:17:50 -04:00
Dave Methvin
6bff3bf7d7 Tests: Remove html5 shiv 2014-01-09 22:36:07 -05:00
Timmy Willison
f9ad13c9ec Manage bower dependencies with grunt-bowercopy
Tracked bower dependencies are located at "src/sizzle" and "test/libs".
The source-destination mapping is in the Gruntfile.

When updating a bower dependency, update the version in bower.json, run
`grunt bower`, and then commit the result. When adding a dependency,
update the bowercopy task accordingly.

Fixes #14615.
Closes gh-1452.
2013-12-06 16:04:35 -05:00
John Paul
b407bddea2 Effects: Integrate sinon fake timers into tests. Close gh-1377. 2013-11-24 15:22:09 -05:00
Timmy Willison
ac7ff97f8b Use grunt and bower packages as local dependencies. Close gh-1433. 2013-11-14 10:17:18 -05:00
Oleg
626cbde7f8 Use full version of jQuery 1.9.1
Had some weird failures in IE with xhr build of 1.9.1
2013-11-08 01:04:08 +01:00
Timmy Willison
5093b89f08 Convert testrunner to an AMD module and ensure jQuery is on the page when executing the testrunner (another race condition amplified by swarm) 2013-09-06 17:11:32 -04:00
Timmy Willison
e563cd3414 Move test loader to testinit.js. Fix race condition with dependency loading. 2013-09-06 16:23:20 -04:00
Timmy Willison
6535cc599e Use requirejs to load the testswarm inject script 2013-09-06 15:44:59 -04:00
Timmy Willison
004c1fc5bb Pass all tests (and load Sizzle fixture correctly) when loading with AMD 2013-08-29 16:18:17 -04:00
Oleg Gaidarenko
70c9a0a13a Fixed pulling in Sizzle subproject when testing with min/dev. 2013-08-16 09:43:43 -04:00
Timmy Willison
6318ae6ab9 AMD-ify jQuery sourcegit s! Woo! Fixes #14113, #14163. 2013-08-15 14:15:49 -04:00
Oleg
c8c32f1d05 Fix paths for qunit files 2013-07-24 18:39:09 +04:00
Timmy Willison
b13d8229ae Include Sizzle and Qunit with bower. Fixes #14118. 2013-07-10 12:00:26 -04:00
Richard Gibson
db0326b1fd Fix #13596; #13722: .replaceWith consistency. Close gh-1216. 2013-04-16 17:47:21 -04:00
Oleg Gaidarenko
f1ba486ee3 Adjust tabIndex propHook for modern browsers and return -1 where appropriate. Close gh-1228. 2013-04-08 21:33:17 -04:00
Michał Gołębiowski
bea0d9a49d Separate test/unit/wrap.js; make tests not fail when wrap module excluded 2013-04-09 00:00:02 +02:00
Richard Gibson
b734666f4d Fix #13265 #13332: traversing methods with text nodes. Close gh-1145. 2013-02-13 22:03:37 -05:00
Richard Gibson
363299ac24 Ref #13316: Sync all documents on full vs. minified source. Close gh-1147. 2013-02-07 15:16:28 -05:00
Oleg
f3db084f7c Fix #13310. Get the right display value for disconnected nodes. Close gh-1156. 2013-02-04 15:22:07 -05:00
Timmy Willison
f3ce0e696d Revert change to visible/hidden selectors until 1.10 and 2.1. Reopens #13132, #10406. 2013-01-30 20:37:13 -05:00
Dave Methvin
58cd84f9d5 Fix #13316. Use minified version in unit testing. 2013-01-26 10:48:10 -05:00
Timmy Willison
b326225d90 Fix failing tests, add support for empty spans in Opera. Supplements #13132, #10406. 2013-01-21 18:03:07 -05:00
Timo Tijhof
55313d32a2 Test: Update index.html to new QUnit format. Close gh-1061.
Depends on jquery/sizzle#177, included with the Sizzle submodule in this commit.
2012-12-10 21:48:20 -05:00
Richard Gibson
d08d48337f update Sizzle 2012-11-16 15:57:43 -05:00
Richard Gibson
48bd8b509b No ticket: speedup effects tests 2012-11-12 21:06:16 -05:00
Richard Gibson
14e1501b89 Fix testing of no-ajax custom builds 2012-11-01 00:40:27 -04:00
Timo Tijhof
6e75fe5f19 No ticket: fix effects test failure in IE6. Close gh-1012. 2012-10-31 16:41:31 -04:00
Timo Tijhof
36c9ecb0f5 Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
  expectation model as reset does .empty() which does a recursive cleanData
  on everything in #qunit-fixture, so any expectJqData above .reset() would
  fail negatively.

  Instead of calling reset inline, either updated the following assertions to
  take previous assertions' state into account, or broke the test() up into
  2 tests at the point where it would call QUnit.reset.

* After introducing the new memory leak discovery a whole bunch of tests were
  failing as they didn't clean up everything. However I didn't (yet) add
  QUnit.expectJqData calls all over the place because in most if not all of
  these cases it is valid data storage. For example in test "data()", there
  will be an internal data key for "parsedAttrs". This particular test isn't
  intending to test for memory leaks, so therefor I made the new discovery
  system only push failures when the test contains at least 1 call to
  QUnit.expectJqData.

  When not, we'll assume that whatever data is being stored is acceptable
  because the relevant elements still exist in the DOM anyway (QUnit.reset
  will remove the elements and clean up the data automatically).

  I did add a "Always check jQuery.data" mode in the test suite that will
  trigger it everywhere. Maybe one day we'll include a call to everywhere,
  but for now I'm keeping the status quo: Only consider data left in storage
  to be a problem if the test says so ("opt-in").

* Had to move #fx-tests inside the fixture because ".remove()" test would
  otherwise remove stuff permanently and cause random other tests to fail
  as "#hide div" would yield an empty collection.
  (Why wasn't this in the fixture in the first place?)

  As a result moving fx-tests into the fixture a whole bunch of tests failed
  that relied on arbitrary stuff about the document-wide or fixture-wide
  state (e.g. number of divs etc.). So I had to adjust various tests to
  limit their sample data to not be so variable and unlimited...

* Moved out tests for expando cleanup into a separate test.

* Fixed implied global variable 'pass' in effects.js that was causing
  "TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
  uses a global variable "pass = function () {};" ...

* Removed spurious calls to _removeData. The new test exposed various failures
  e.g. where div[0] isn't being assigned any data anyway.
  (queue.js and attributes.js toggleClass).

* Removed spurious clean up at the bottom of test() functions that are
  already covered by the teardown (calling QUnit.reset or removeClass to
  supposedly undo any changes).

* Documented the parentheses-less magic line in toggleClass. It appeared that
  it would always keep the current class name if there was any (since the
  assignment started with "this.className || ...".

  Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
  Only added the comment for now, though I prefer clarity with logical
  operators, I'd rather not face the yayMinPD[1] in this test-related commit.

* Updated QUnit urlConfig to the new format (raw string is deprecated).

* Clean up odd htmlentities in test titles, QUnit escapes this.
  (^\s+test\(.*)(&gt\;) → $1>
  (^\s+test\(.*)(&lt\;) → $1<

[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-28 22:44:57 -04:00
Dave Methvin
2a1e5eccf5 Shim/shiv the datalist element for crabby Uncle oldIE. 2012-09-05 22:01:35 -04:00
Dave Methvin
3016872220 Let subproject tests use their own test fixture. Closes gh-867. 2012-07-19 22:02:37 -04:00