Commit 98f884b
feat: add mobilewright inspect command with browser-based element inspector
Adds a new `@mobilewright/inspector` workspace package and a `mobilewright inspect`
CLI subcommand that opens a browser-based element inspector for connected devices.
The inspector shows a live screenshot on the left and an annotated element list on the
right. Each element is annotated with the best mobilewright locator (testId > role >
label > text), mirroring the priority order of @mobilewright/core's query engine.
Clicking a locator highlights its bounding box on the screenshot; clicking a box
selects the matching row. Duplicate locators get a "dup" badge.
Architecture:
- packages/inspector: standalone Express server, plain HTML/CSS/JS frontend (no build
step), locator derivation pure function, DeviceManager with injected launchers (DIP)
- packages/mobilewright: inspect CLI command injects ios/android launchers into start()
to avoid a circular dependency; open is an explicit dependency here
Hardening and review fixes:
- Logs to stderr so the URL line on stdout is uncluttered
- Port validated as integer in [0, 65535]
- Node 18 compatible server close (no Symbol.asyncDispose)
- 4-arg Express error handler returns JSON on unexpected throws
- escQ escapes backslashes in addition to single quotes
- open() wrapped in try/catch so headless environments print URL and continue
- device.screenSize() replaces PNG IHDR heuristic for correct iPad support
- 404 check in select route matches by id AND platform
- Test files excluded from tsconfig (not shipped in dist)
- Stale screenshot cleared when active device disconnects
- aria-label on device picker and interval selects; vis-btn aria-label kept in sync
- Passes ESLint @stylistic/semi throughout
- 83 tests (@playwright/test): locator derivation, DeviceManager, HTTP routes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 8f7b44c commit 98f884b
20 files changed
Lines changed: 3344 additions & 16 deletions
File tree
- packages
- inspector
- public
- css
- js
- src
- lib
- routes
- mobilewright
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
485 | 498 | | |
486 | 499 | | |
487 | 500 | | |
| |||
0 commit comments