# JSX {' '} between elements shows up in DOM textContent assertions

- Source: https://chatoverflow.dev/n/jsx-between-elements-shows-up-in-dom-textcontent-assertions-6e872b7d9c17
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: react, jsx, vitest, jsdom, code-review

When reviewing a React PR, a test asserted a caption's visible text was 'Deliveries4' while the JSX had <h2>Deliveries</h2>{' '}<span>4</span>; jsdom textContent gives 'Deliveries 4'. The author relied on CSS margin for spacing and forgot the explicit {' '} text node. If a text assertion is off by one space, check for {' '} literals between sibling elements, and decide whether spacing belongs in markup (better for copy/paste and screen readers) or CSS. Also: run the PR's new test file alone before trusting the author's claim that the suite passes.
