Skip to content

docs(web): add Testing guide [SDC-31986] - #407

Merged
eatsjobs merged 5 commits into
mainfrom
feature/SDC-31986-web-testing-docs
Aug 5, 2026
Merged

docs(web): add Testing guide [SDC-31986]#407
eatsjobs merged 5 commits into
mainfrom
feature/SDC-31986-web-testing-docs

Conversation

@eatsjobs

Copy link
Copy Markdown
Contributor

Adds a Web Testing page (docs/sdks/web/testing.md), linked in the Web sidebar next to Agent Skills. Companion to the iOS guide (#378, merged) and Android guide (#377, open) for SDC-31976/SDC-31985/SDC-31986.

What's covered

  • Two approaches (use either/both): isolate the SDK behind your own abstraction, or test with the SDK's own types directly — for every mode the ticket covers: Barcode Capture, MatrixScan (BarcodeBatch), ID Capture, SparkScan, plus FrameData.
  • Why Web is lighter-weight than iOS/Android: the public types are plain TypeScript classes/interfaces, not final/native-backed, so no mocking framework (OCMockito, MockK, Mockito) is needed — a plain object literal stands in for anything the SDK would otherwise hand your listener.
  • Two integration-testing options, since the ticket reporter asked for both to be documented:
    • ImageFrameSource — the SDK's own built-in frame source; bypasses the camera/getUserMedia entirely and feeds a static image straight into the pipeline. Lightest-weight when you only need to verify real decoding.
    • @eatsjobs/media-mock — mocks getUserMedia at the browser API level, for when the code under test specifically drives the camera (e.g. permission handling) and you want the real Camera frame source to run unmodified.

Validation

  • npm run build (Docusaurus) succeeds with no errors; verified the rendered page and its sidebar entry.
  • Every code sample is cross-checked against the real SDK source (web-datacapture-{barcode,core,id}), reusing verification already done for the in-repo Sphinx guide in data-capture-sdk!37490.
  • No code-snippet CI validator exists for TypeScript in this repo yet (only kotlin/java), matching the iOS PR's approach rather than Android's.

🤖 Generated with Claude Code

eatsjobs and others added 5 commits July 30, 2026 09:20
Adds a Web Testing page (docs/sdks/web/testing.md), linked in the Web
sidebar next to Agent Skills. Companion to the iOS (#378) and Android
(#377) guides.

Covers isolating the SDK behind your own abstraction, testing with the
SDK's own types directly (no mocking framework needed on Web, unlike
iOS/Android, since the public types are plain TS classes/interfaces),
and integration testing the real pipeline two ways: the built-in
ImageFrameSource (bypasses the camera entirely) and @eatsjobs/media-mock
(mocks getUserMedia when the code under test drives the camera itself).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ce mapping

Adds the verified page.route gate (Playwright's addInitScript does not
block the page's own script), the reusable mockCameraStream fixture,
and the mediaMockDevice per-project mapping for testing across browser
engines and form factors (media-mock ships iPhone 12, Samsung Galaxy
M53, and Mac Desktop). All match the real, passing implementation in
BarcodeCaptureSimpleSample (data-capture-sdk!37490).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reflects what BarcodeCaptureSimpleSample's e2e/ actually ships now:
mocking wrapped in a MediaMockFacade class instead of a bare fixture
function, and the test.describe/beforeEach/afterEach structure. Drops
the page.route/scanditTestMediaMockReady gate now that
@eatsjobs/media-mock@2.0.2 fixes the underlying setSource race
internally.
The e2e/ Playwright setup isn't part of what gets published to the
public sample mirror, so don't claim a browsable GitHub path for it.
…wright hardening

Broaden the isolation example to mirror Android/iOS's pattern, restore the
missing ID Capture unit-test example, and align setupScanner with the real
BarcodeCaptureSimpleSample sequence. Add guidance for enabling WebGL and
multithreading under Playwright, and note Chromium's built-in fake-video-file
option ahead of introducing media-mock.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@anthonypenna anthonypenna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@eatsjobs
eatsjobs merged commit ac7c0a2 into main Aug 5, 2026
2 checks passed
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.

2 participants