Skip to content

feat(runner): make TestRunner#viewportScope public for headless runners - #446

Merged
kevinccbsg merged 1 commit into
mainfrom
feat/public-viewport-scope
Nov 20, 2026
Merged

kevinccbsg merged 1 commit into
mainfrom
feat/public-viewport-scope

Conversation

@kevinccbsg

Copy link
Copy Markdown
Member

Part of #444, the hook twd-cli needs for responsive runs.

TestRunner#viewportScope(options?) was private. It is now public, unchanged:

  • no argument: ids of the tests in scope at the current window width
  • { viewport: 'mobile' }: ids of the tests for that viewport, without resizing
  • null when the app declares no viewports

twd-cli calls it from the page (new window.__testRunner(events).viewportScope()) to plan one pass per viewport and to check, after each resize, that the width matches. That way the matching rules live only in twd-js.

Changes

  • src/runner.ts: viewportScope drops private, with a doc comment for tools.
  • src/tests/runner/twd-runner-viewport.spec.ts: covers null without viewports, current width, a named viewport, defaultViewport, and access through window.__testRunner. Written first; it failed the type check while the method was private.
  • specs/2026-11-19-responsive-testing-design.md: section 9 describes the refined twd-cli flow (one page load, no reload, each test runs once).

628 tests pass, 0 lint errors.

twd-cli plans one pass per viewport from the page. With the scope public it
asks twd-js which tests match instead of reimplementing the matching rules.
@kevinccbsg
kevinccbsg merged commit 7f1877f into main Nov 20, 2026
10 checks passed
@kevinccbsg
kevinccbsg deleted the feat/public-viewport-scope branch November 20, 2026 10:17
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.

1 participant