Tests: jquery + native DOM backends#497
Conversation
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.21...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
The local browser tests, as well as CI, are now fully compatible with adding or removing jquery in a reproducible way.
Run dual mode in local browser tests:First, cd to no jquery meteor npm run test:watch # runs 412 testsqith jquery meteor npm run test:jquery # runs 416 testsRun dual mode in
|
There was a problem hiding this comment.
Pull request overview
This PR updates Meteor/Blaze’s test infrastructure and several package test suites to run cleanly in both DOM backends: with jQuery present (legacy behavior) and without jQuery (native DOM backend).
Changes:
- Adds a jQuery-free
test-in-browserdriver/package and updates CI to run the test suite both with and without--extra-packages=jquery. - Refactors Blaze/Spacebars/Observe-sequence tests to avoid direct jQuery usage and to tolerate either backend.
- Updates Blaze’s DOM backend implementation for native event delegation + teardown behavior, and bumps the test app Meteor release/deps.
Reviewed changes
Copilot reviewed 25 out of 28 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| test-app/package.json | Removes npm jQuery dep; adds test:jquery script; bumps dependencies. |
| test-app/.meteor/versions | Updates pinned Meteor package versions for the test app. |
| test-app/.meteor/release | Bumps test app Meteor release to METEOR@3.4. |
| test-app/.meteor/packages | Updates test app package pins to match the newer Meteor release. |
| site/package-lock.json | Updates site lockfile dependency graph (incl. lodash entry update). |
| packages/test-in-browser/server.js | Adds server-side autoupdate salt tweak to force reloads during browser testing. |
| packages/test-in-browser/README.md | Adds stub package README explaining temporary nature. |
| packages/test-in-browser/package.js | Introduces a stub test-in-browser package without jQuery. |
| packages/test-in-browser/driver.js | New jQuery-free browser test runner UI/logic. |
| packages/test-in-browser/driver.html | New Blaze templates for the browser test runner UI. |
| packages/test-in-browser/driver.css | New styling for the browser test runner UI. |
| packages/test-in-browser/.npm/package/README | Generated metadata for Meteor package npm deps. |
| packages/test-in-browser/.npm/package/npm-shrinkwrap.json | Locks npm deps for test-in-browser (bootstrap/diff). |
| packages/test-in-browser/.npm/package/.gitignore | Ignores node_modules for the package’s npm deps. |
| packages/test-in-browser/.gitignore | Ignores package build artifacts. |
| packages/spacebars-tests/templating_tests.js | Makes DOM interactions compatible with both jQuery and native DOM. |
| packages/spacebars-tests/template_tests.js | Removes/guards jQuery usage; adds native event triggering helpers; converts some tests to async. |
| packages/spacebars-tests/old_templates_tests.js | Mirrors template_tests backend-agnostic updates for legacy templates. |
| packages/spacebars-tests/package.js | Removes strong test dependency on jquery package. |
| packages/spacebars-tests/.versions | Removes jquery from pinned test package versions. |
| packages/observe-sequence/observe_sequence_tests.js | Converts multiple tests to Tinytest.addAsync and awaits shared helpers. |
| packages/blaze/render_tests.js | Updates tests to pass with or without jQuery-backed DOM backend. |
| packages/blaze/package.js | Makes jQuery a client-only weak dependency; removes strong dependency from Blaze’s tests. |
| packages/blaze/materializer.js | Adjusts promise/thenable handling in materialization flow. |
| packages/blaze/dombackend.js | Adds jQuery detection/logging; native parseHTML path; native delegation wrapper changes; native teardown hooks including remove() override. |
| packages/blaze/blaze.d.ts | Removes jquery import while still referencing $ types. |
| packages/blaze/.versions | Removes jquery from pinned Blaze package versions. |
| .github/workflows/blaze-tests.yml | Adds a second CI job to run tests with --extra-packages=jquery. |
Files not reviewed (2)
- packages/test-in-browser/.npm/package/npm-shrinkwrap.json: Language not supported
- site/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@dupontbertrand do you have some time to spare to take a look at this one? |
|
@dupontbertrand all comments are addressed in 6c20849 and 79a5299 |
|
@dupontbertrand thanks, fortunately this mistake occurred and you detected it, because the current tests never branched into any of the manual event triggers, because the I therefore added in 46edae1 some explicit tests that only cover manual event dispatching of focus/blur |
This is a follow up on #493 which adjusts the tests to be compatible with and without jQuery.
test-in-browser(attention, this is a core package)Findings form initial research
📢 Update: all of the issues below were addressed in this PR, see comments further below
1. tests satisfaction
This PR focused only on passing tests when DOM backend is native AND if jQuery is used.
2. jQuery in tests
Many tests used jquery by default, for example to find or remove elements:
This causes the native DOM backend to fail, because there is no native communication between the removal and the Teardown (which removes reactive listeners etc.).
As a solution, the native
HTMLElement.prototype.removemethod gets overridden to call the teardown for the element and its children.This needs to be tested appropriately using apps.
3. template scoped events
With jQuery, events are automatically scoped to the template level. This prevents event selector in a child template to bubble up the event to the parent template, if the selector matches.
As a solution, the parent chain is traversed upwards to see if a view is associated and if it changed, once the selector does not match the current element anymore.
This needs to be tested appropriately using apps.
4. external dependencies
The weak dependency of jQuery automatically loads, once any other package has loaded jQuery. However, the
test-in-browser(peer-dep of Tinytest via tinytest-harness) causes jQuery to be included in any case.This is therefore on hold, until
test-in-browserhas jQuery removed.Once this is done, we can leverage an env variable to include jQuery in tests, without adding it as a dependency and adjust CI to run tests with jQuery and with native DOM backend.