Test a generated sitemap against the built pages and an explicit list of eligible routes before deployment.
Build the example
Parse XML with a parser and collect canonical locations. Reject duplicates, unexpected origins, drafts, fragment URLs and paths without built HTML. Verify the reverse mapping too: every intended indexable route should appear exactly once. For a server-rendered site, use the route registry or preview responses instead of requiring a physical HTML file.
Make the fixture include a URL whose trailing slash differs from the canonical HTML. A local file may exist for that URL while the live host returns a redirect, so check the public response as a separate deployment smoke test. Report drafts, duplicates, missing pages and redirecting canonicals as different failure categories.
Two-way sitemap coverage
Test a generated sitemap against the built pages and an explicit list of eligible routes before deployment.
Example
- Sitemap to registry
reject unexpected or ineligible routes
- Registry to sitemap
find missing routes
- HTML
check canonical and indexability
check canonical and indexability
Watch the failure boundary
Store a list of expected canonical routes from the same content registry used to render pages. Keep the assertion independent enough to catch accidental exclusions, such as verifying known public posts as fixtures. Include sitemap escaping and XML parsing in the test if any URL can contain characters with XML meaning.
Verify the behavior
Create a fixture with a duplicate, a draft and an omitted article. Report all three independently. Check that the final HTML canonical agrees with the sitemap location. Sitemap inclusion helps discovery and should be reported separately from whether a search engine selected the URL.
Sources
Technical references checked .



