Skip to content

feat: add testing helpers for sitemap-driven smoke tests - #316

Merged
Walkeezy merged 4 commits into
mainfrom
feat/testing
Oct 8, 2026
Merged

Walkeezy merged 4 commits into
mainfrom
feat/testing

Conversation

@Walkeezy

@Walkeezy Walkeezy commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds two new subpaths for sitemap-driven smoke tests:

  • @smartive/utils/testing: no dependencies, no browser.
    • fetchSitemapRoutes follows sitemap indexes, includes hreflang alternates, applies excludes and limits, and fails when the sitemap is empty.
    • checkUrls checks every URL's status without following redirects and retries 5xx and network errors.
    • Also exports the helpers (parseSitemap, limitRoutes, excludeRoutes, toPath, isIgnored).
  • @smartive/utils/testing/playwright: an automatic smoke fixture.
    • Blocks third-party requests (with an allowHosts allowlist).
    • Fails the test on console errors and warnings, uncaught exceptions, unhandled rejections and failed first-party requests.
    • Includes gotoAndSettle, and smokeGlobalSetup/readRoutes to generate one test per sitemap route.

@playwright/test is an optional peer dependency. Only its types are imported, so the project's pinned version is the one that runs. Both subpaths have a default export condition, so CommonJS projects (most Next.js apps) can use them.

Notes

  • Per-file test.use({ smokeOptions }) overrides are merged over the smokeFixtures() options: ignore and allowHosts add to them, the other fields replace them.
  • The README has a full recipe: Playwright config, global setup, fixtures, specs and GitLab CI.

Tests

  • Unit tests (vitest) for sitemap parsing, route limits, the URL checker, ignore rules and the fixture.
  • New Playwright e2e suite against a local fixture server (npm run test:e2e), plus a check that both subpaths load via require(). A new CI job runs it.

Walkeezy and others added 4 commits October 8, 2026 09:51
Add `@smartive/utils/testing` (sitemap parsing, route limits, ignore
rules, browserless URL check) and `@smartive/utils/testing/playwright`
(fixtures that fail a test on client-side errors, third-party request
blocking, global setup that hands sitemap routes to the specs).

`@playwright/test` is an optional peer and only imported as types, so
each project runs the version pinned to its CI image. Both subpaths have
a `default` export condition so CommonJS projects can require them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xture server

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… first-party checks

`test.use({ smokeOptions })` replaced the options passed to `smokeFixtures()`, silently
dropping the project-wide `allowHosts` and `ignore` rules. Overrides are now merged:
`ignore` and `allowHosts` add to the base options, the other fields replace them.

`checkFirstPartyRequests: false` still failed on first-party 404s through Chromium's
"Failed to load resource" console error. That message is now always skipped for
first-party URLs, since the response and requestfailed handlers own those failures.

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

The smoke fixture only knew Chromium's abort error, so cancelled first-party
requests (video range requests, navigating away) failed tests in Firefox
(`NS_BINDING_ABORTED`) and WebKit (`cancelled`, `Load request cancelled` on
Linux). The never-matching `ERR_BLOCKED_BY_CLIENT` entry is gone.

Firefox reports a blocked script as a console warning that names the URL in
its text but gives the page as location, which failed every page with a
blocked tracker. Console messages naming a blocked URL are now skipped.

`fetchSitemapRoutes` takes a `timeoutMs` (default 30 s) per request and adds
the sitemap URL to network and timeout errors, so a hanging sitemap fails the
global setup instead of stalling it.

The fixture e2e spec now also runs in Firefox and WebKit on CI (opt-in locally
via `E2E_ALL_BROWSERS`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Walkeezy
Walkeezy merged commit d9fa5e8 into main Oct 8, 2026
2 checks passed
@Walkeezy
Walkeezy deleted the feat/testing branch October 8, 2026 10:27
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 4.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant