Skip to content

Conversation

@hristoterezov
Copy link
Member

Summary

This PR adds comprehensive test infrastructure to validate the querySelector/querySelectorAll polyfill from @jitsi/js-utils (v2.6.7) by running all existing tests in both native browser and React Native simulation environments.

Motivation

React Native doesn't provide native querySelector/querySelectorAll APIs. We've implemented a polyfill in js-utils, and this PR ensures all existing lib-jitsi-meet code works correctly with the polyfill before deploying to React Native.

Changes

  • Updated @jitsi/js-utils from 2.4.6 to 2.6.7 (includes querySelector polyfill)
  • Added test-setup-polyfill.ts: Global test setup that overrides native querySelector APIs with the polyfill implementation
  • Added karma-polyfill.conf.js: Karma configuration for running tests with polyfill active
  • Updated npm scripts:
    • npm run test - Runs both native and polyfill tests sequentially
    • npm run test:native - Tests with native browser querySelector
    • npm run test:polyfill - Tests with querySelector polyfill (React Native simulation)

Test Results

All 384 existing tests pass in both environments:

  • Native environment: 384/384 tests passed
  • Polyfill environment: 384/384 tests passed

This confirms the polyfill correctly handles all real-world XMPP/Jingle XML processing scenarios including:

  • Simple tag name selectors
  • Attribute selectors with namespaces
  • :scope > direct child selectors
  • Complex nested structures
  • STUN/TURN service discovery
  • Jingle session negotiation

Testing Strategy

Dual-environment approach ensures compatibility:

  1. Tests run first with native browser querySelector (baseline)
  2. Tests run again with polyfill overriding native APIs (React Native simulation)
  3. Sequential execution provides clear feedback on which environment fails

Future Work

This infrastructure will automatically validate all future code changes work in both web and mobile environments.

xmldom Consideration

No additional testing with xmldom is needed because:

  • xmldom is DOM spec-compliant and implements getElementsByTagName correctly
  • The polyfill's logic (selector parsing, matching, traversal) is what we're testing
  • 384 tests validate the polyfill works correctly with DOM primitives
  • Low risk of environment-specific issues

Enable validation of querySelector/querySelectorAll polyfill compatibility
by running all existing tests in both native browser and React Native
simulation environments. This ensures the codebase works correctly across
web and mobile platforms.

Changes:
- Update @jitsi/js-utils to 2.6.7 with querySelector polyfill support
- Add test-setup-polyfill.ts to override native querySelector APIs
- Add karma-polyfill.conf.js for React Native simulation testing
- Add npm scripts: test:native, test:polyfill for environment-specific runs
- Update main test script to run both environments sequentially

All 384 existing tests pass in both environments, confirming polyfill
compatibility with real-world XMPP/Jingle XML processing.
@hristoterezov hristoterezov force-pushed the test-querySelector-polyfill branch from e8e085d to 96b9ec9 Compare October 22, 2025 22:37
@hristoterezov hristoterezov marked this pull request as ready for review October 23, 2025 17:21
@hristoterezov hristoterezov merged commit efdddec into master Oct 23, 2025
2 checks passed
@hristoterezov hristoterezov deleted the test-querySelector-polyfill branch October 23, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants