Skip to content

feat(core): add dangerouslyEnableTestHooks and run Node E2E against a production build - #7

Open
ostenbom wants to merge 3 commits into
mainfrom
e2e/production-build-flag
Open

ostenbom wants to merge 3 commits into
mainfrom
e2e/production-build-flag

Conversation

@ostenbom

@ostenbom ostenbom commented Oct 27, 2026 •

Copy link
Copy Markdown

What does this PR do?

Most of the Node E2E time goes to astro dev, and running the suite against a real production build was the biggest win I found. The catch is that the suite needs dev-only endpoints.

This PR adds a build-time dangerouslyEnableTestHooks option to emdash(). Those call sites now go through isDevOnlyEnabled(), which checks import.meta.env.DEV or a Vite define set by the option. Because the value is fixed at build time, a normal build compiles the check down to return false;, and no env var or request can turn it on. astro build warns while the option is on, and only the E2E fixture sets it.

The E2E side is the same as #6: EMDASH_E2E_BUILD=production builds and serves the fixture for the Node step only, with the same fixture changes for running as a built site. The shard layout is unchanged.

Node E2E on CI (8 shards) Slowest shard Total across shards
astro dev (main) 7.1 min 35.4 min
astro build --devOutput (#6) 5.5 min (−23%) 24.1 min (−32%)
astro build + dangerouslyEnableTestHooks (this PR) 2.8 min (−61%) 14.6 min (−59%)

#6 is the no-new-option alternative. For a full local run you also need #10. On Endform this build runs the whole suite in one job in under 6 minutes, install and build included (#9).

I used claude to help me create this PR, but I have run the suite and reviewed the code myself.

Type of change

  • Bug fix
  • Feature (requires an accepted feature plan or RFC)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Your connection to this change

  • I use EmDash and ran into the problem this PR addresses
  • I maintain a tool, dependency, or service that EmDash uses, and this change concerns that integration
  • A Maintainer approved this specific change before I opened the PR

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change): core unit tests (6100 passed), full Node E2E suite against the production build (see table); core integration tests not run locally
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable): not applicable, no admin UI change
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to their merged design PR: none; approach discussed with a maintainer
  • I have included screenshots below if this PR changes the UI: not applicable

AI assistance disclosure

  • This PR includes AI-generated code or text — model/tool: Claude Opus 5.5 (Claude Code)

Screenshots / test output

Not applicable.

@github-actions

Copy link
Copy Markdown

PR template validation failed

Please fix the following issues by editing your PR description:

  • Feature PRs require a link to their merged design PR. Follow the feature-plan or RFC process in proposals/README.md first.

See CONTRIBUTING.md for the full contribution policy.

ostenbom and others added 3 commits October 27, 2026 13:45
The dev-bypass, dev-reset and captured-email endpoints, the console
email provider and localhost registry URLs are gated on
import.meta.env.DEV, so an end-to-end suite that signs in through them
can only run against `astro dev`.

The new integration option sets a build-time constant that the shared
isDevOnlyEnabled() gate reads alongside import.meta.env.DEV. A build
without the option gets `false`, so nothing at runtime can switch the
endpoints on, and the build-time registry check accepts localhost only
when the option is set. `astro build` warns while it is on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EMDASH_E2E_BUILD=production now runs `astro build` on the Node fixture
and serves dist/server/entry.mjs instead of running `astro dev`. The
fixture sets dangerouslyEnableTestHooks so the suite can still sign in
and reset the site, and EMDASH_SITE_URL because production setup and
image.remotePatterns need it.

Also fixes what a built fixture exposes: manual i18n routing so the
fixture's [locale] pages win over Astro's fallback routes, sharp for
the image endpoint, the registry fixture installed at server start, an
https image URL for the CSP, and an ignore rule for the migrations
journal that builds write into the fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant