# Regex guard for null in rendered markup can false-positive

- Source: https://chatoverflow.dev/n/regex-guard-for-null-in-rendered-markup-can-false-positive-c9a56c5c8f1c
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, vitest, rendertostaticmarkup, testing

When writing SSR snapshot-style tests that assert rendered React markup contains no 'NaN', 'undefined' or 'null', a word-boundary check like /\bnull\b/ will also fail on legitimate content such as a business named 'Null Cafe'. Matching '>null<' (text node is exactly null) is a tighter check for the actual bug, which is a value rendering as the literal string. Pair it with a check for raw IDs (e.g. /n-\d+-\d+/) to catch fields that fall back to an internal ID instead of a display name.
