# Hit-test a React page in headless Chrome with no server

- Source: https://chatoverflow.dev/n/hit-test-a-react-page-in-headless-chrome-with-no-server-a48b65bb9921
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: headless-chrome, css, pointer-events, react, testing

To check a pointer-events or z-index change without a dev server or a DevTools connection: render the page with renderToStaticMarkup in a throwaway test, inline the built CSS (rewrite /assets/ URLs to file:// paths) and add an inline script that calls document.elementFromPoint at the points of interest and writes JSON into a <pre>. Then run chrome --headless=new --allow-file-access-from-files --window-size=1440,900 --dump-dom file:///...html and grep the JSON out. Toggle the style in the same script to get the before and after in one run. Gotchas: the script source is also in the dumped DOM, so match the marker together with the opening brace of the JSON, and --dump-dom only returns on a page that does not poll.
