Skip to content

Tests: jquery + native DOM backends#497

Open
jankapunkt wants to merge 18 commits intorelease-3.1.0from
tests/jquery
Open

Tests: jquery + native DOM backends#497
jankapunkt wants to merge 18 commits intorelease-3.1.0from
tests/jquery

Conversation

@jankapunkt
Copy link
Copy Markdown
Collaborator

@jankapunkt jankapunkt commented Mar 31, 2026

This is a follow up on #493 which adjusts the tests to be compatible with and without jQuery.

  • remove all direct jQuery dependencies in Blaze packages
  • remove jquery dependencies in test-in-browser (attention, this is a core package)
  • pass all tests with jQuery
  • pass all tests without jQuery
  • fix Teardown for native DOM backend
  • fix event delegation for native DOM backend
  • adapt CI to run testsuite with both setups in sequence (first using native, then jQuery)

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:

$(div).remove()

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.remove method 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-browser has 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.

@jankapunkt jankapunkt mentioned this pull request Mar 31, 2026
18 tasks
@jankapunkt jankapunkt changed the title Tests/jquery Tests: jquery + native DOM backends Mar 31, 2026
@jankapunkt jankapunkt marked this pull request as ready for review April 8, 2026 07:54
@jankapunkt
Copy link
Copy Markdown
Collaborator Author

jankapunkt commented Apr 8, 2026

The local browser tests, as well as CI, are now fully compatible with adding or removing jquery in a reproducible way.

  1. jquery is now a weak dependency on blaze package, which holds the dombackend
  2. by default, no packages in the package bundle contains jquery, causing the default test suite to run using the native DOMBackend
  3. the modified test-in-browser package has no jquery dependency anymore and is for now added as a local package (test-only) to this repository until packages: remove jQuery from test-in-browser meteor#14308 is fully resolved.
  4. the test suite runs some extra tests in jquery mode, that are only related to jquery behavior
  5. no modification for test-in-console needed

Run dual mode in local browser tests:

First, cd to test-app and install npm deps, then

no jquery

meteor npm run test:watch # runs 412 tests

qith jquery

meteor npm run test:jquery # runs 416 tests

Run dual mode in test-in-console

As the CI uses test-in-console by default the native DOM backend is used. If jquery should be used, add --extra-packages=jquery to the test command.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-browser driver/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.

jankapunkt and others added 2 commits April 8, 2026 10:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jankapunkt jankapunkt added this to the 3.1 milestone Apr 8, 2026
@jankapunkt jankapunkt added dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code ready2review feel free to add your review to this PR labels Apr 9, 2026
@jankapunkt
Copy link
Copy Markdown
Collaborator Author

@dupontbertrand do you have some time to spare to take a look at this one?

@jankapunkt jankapunkt requested a review from zodern April 10, 2026 11:57
Copy link
Copy Markdown

@dupontbertrand dupontbertrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incoming..

@jankapunkt
Copy link
Copy Markdown
Collaborator Author

@dupontbertrand all comments are addressed in 6c20849 and 79a5299

if (hasJquery) {
$(input).trigger('focus');
} else {
trigger({ el: input, eventName: 'focusin', bubbles: true });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's eventName or eventType here ?

if (hasJquery) {
$(input).trigger('blur');
} else {
trigger({ el: input, eventName: 'focusout', bubbles: true });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's eventName or eventType here ?

if (hasJquery) {
$(input).trigger('focus');
} else {
trigger({ el: input, eventName: 'focusin', bubbles: true });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's eventName or eventType here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code ready2review feel free to add your review to this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants