Skip to content

fix: return JS values and errors in inspect, avoid SVG panic, and fix snapshot paths - #115

Open
domfahey wants to merge 5 commits into
RealGeeks:mainfrom
domfahey:fix/browser-inspect-and-snapshot
Open

domfahey wants to merge 5 commits into
RealGeeks:mainfrom
domfahey:fix/browser-inspect-and-snapshot

Conversation

@domfahey

@domfahey domfahey commented Nov 25, 2026 •

Copy link
Copy Markdown

Fixes edge cases in inspect and snapshot. 7 files: about 470 lines of source, about 200 lines of tests.

Behaviour changes

Command Before After
inspect --js / --assert thrown errors ignored (--assert "throw true" passed); objects came back empty JS errors fail the command; objects, arrays and null come back as JSON; NaN/Infinity/BigInt as strings ("NaN")
inspect --text svg panicked returns the element's text
invalid selector (div[) "no element matches" browser query failed, the same from every option
snapshot buying / HTTPS://… / /a b/ wrong or percent-encoded default file name snapshot-buying.png, snapshot-a-b.png; scheme normalized to lowercase
--mobile --scale 2 --scale silently ignored usage error (documented in --help and the guide)
Windows browser lookup extensionless shim could win PATHEXT matches are tried first

Where to look

  • decode_eval_result in src/commands/inspect.rs: how a JS result becomes JSON or an error.
  • resolve_url / default_out in src/commands/snapshot.rs.
  • Tests: tests/inspect.rs and tests/snapshot.rs drive a real Chrome when one is installed and skip otherwise.

percent-encoding is now a direct dependency; it was already in Cargo.lock through url.

Checklist

  • cargo fmt, cargo clippy --all-targets -- -D warnings and cargo test pass
  • Behaviour changes documented in docs/GUIDE.md and --help
  • No API keys, customer data or private site content

@domfahey
domfahey force-pushed the fix/browser-inspect-and-snapshot branch from ef0a680 to 7a52305 Compare November 25, 2026 03:57
domfahey and others added 3 commits November 24, 2026 23:25
…t non-JSON numbers

- default snapshot names slug the percent-decoded path, so `/search results/`
  gives snapshot-search-results.png instead of snapshot-search-20results.png
- resolve_url lowercases the scheme of a full URL (`HTTPS://…` → `https://…`)
- --js/--assert return NaN, ±Infinity, -0 and BigInts as strings instead of
  failing with "did not return a JSON value"
- --count reports an invalid selector as `browser query failed`, like the
  other selector operations
- document that --mobile cannot be combined with --width/--height/--scale

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@domfahey

domfahey commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

Hi! This is the first of a few small PRs; I'll send them one at a time.

What it does: fixes inspect and snapshot edge cases. The table in the description lists each before/after. 7 files, about two-thirds source and one-third tests.

Worth a look: decode_eval_result in src/commands/inspect.rs. It handles exceptions, null/undefined, and NaN/Infinity returned as strings.

Note: the workflow runs are waiting for maintainer approval because this comes from a fork. Could you approve them? Locally, fmt, clippy and test all pass.

Queued behind it: #114 (search parsing and validation) and #116 (tests and coverage).

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