Skip to content

fix(tests): correct unit tests that pass without verifying behavior#5012

Open
PascalThuet wants to merge 3 commits into
Dash-Industry-Forum:developmentfrom
PascalThuet:fix/ineffective-unit-tests
Open

fix(tests): correct unit tests that pass without verifying behavior#5012
PascalThuet wants to merge 3 commits into
Dash-Industry-Forum:developmentfrom
PascalThuet:fix/ineffective-unit-tests

Conversation

@PascalThuet
Copy link
Copy Markdown
Contributor

@PascalThuet PascalThuet commented Apr 5, 2026

Summary

Fixes 4 unit tests that counted as "passed" without actually exercising the code they describe, fixes the parser bug they were hiding, and adds a missing test for Patch parsing. See #5011 for the full analysis.

Test fixes (commit 1):

  1. dash.DashParser.js lines 17-28 — replace .bind() with arrow functions so parse() is actually called
  2. mss.parser.MssParser.js line 62 — same .bind() fix
  3. dash.DashParser.js line 64 — move await from unsupported async describe() into a before() hook
  4. streaming.Stream.js lines 93-98await the Promise from setMediaSource() so the assertion runs before Mocha marks the test as passed

Parser fix (commit 2):

Fixing the .bind() pattern revealed that DashParser.parse() does not reject non-MPD XML input. parseXml() returns a non-null object for any parseable string, so the existing if (!manifest) guard passes, and the code crashes later on .protocol access.

The fix strengthens the validation gate to check for MPD or Patch root elements: if (!manifest || (!manifest.MPD && !manifest.Patch)).

New test (commit 3):

Adds a test verifying that parse() correctly handles valid Patch XML input (MPD Patch per DASH-IF spec), exercising the manifest.Patch branch that was previously untested.

Impact

Metric Before (development) After (this PR)
Tests executed 3612 3616
Tests passing 3612 3616
Tests failing 0 0
Silently ineffective tests 8 0
Parser bug hidden by tests 1 fixed

Test plan

  • All unit tests pass in CI (Chrome + Firefox)
  • DashParser correctly rejects non-MPD input with 'failed to parse the manifest'
  • DashParser correctly parses valid Patch XML
  • MssParser correctly rejects invalid MSS input

Fixes #5011

🤖 Generated with Claude Code

PascalThuet and others added 3 commits April 5, 2026 08:00
- DashParser: replace .bind() with arrow functions so parse() is
  actually called with the intended arguments (lines 17-28)
- DashParser: move async fixture loading from describe() scope into
  a before() hook — Mocha does not support async describe (line 64)
- MssParser: same .bind() fix (line 62)
- Stream: await the Promise from setMediaSource() so the assertion
  runs before Mocha marks the test as passed (lines 93-98)

Fixes Dash-Industry-Forum#5011

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
parseXml() can return a non-null object for any parseable XML-like
string. The existing guard only checked for null, so non-MPD input
(e.g. plain text) would pass validation and crash later when accessing
.protocol on undefined.

Add a check for the presence of MPD or Patch root elements before
proceeding. This gives callers the expected 'failed to parse the
manifest' error instead of a cryptic property access error.

Bug exposed by fixing the .bind() test pattern in Dash-Industry-Forum#5012.

Refs Dash-Industry-Forum#5011

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Fix unit tests that pass without verifying the intended behavior

2 participants