Skip to content

chore: run the production CSP and cookie unit tests - #17436

Merged
teemingc merged 2 commits into
sveltejs:mainfrom
xyrolle:chore/run-prod-csp-cookie-tests
Oct 21, 2026
Merged

teemingc merged 2 commits into
sveltejs:mainfrom
xyrolle:chore/run-prod-csp-cookie-tests

Conversation

@xyrolle

@xyrolle xyrolle commented Oct 14, 2026

Copy link
Copy Markdown

The CSPs in prod block in csp.spec.js and the cookies in prod block in cookie.spec.js don't run in any project. They are skipped when process.env.DEV is set, and Vitest sets process.env.DEV to '1' itself (it mirrors import.meta.env), so they are skipped in kit-server-dev as well as in kit-server-build, which sets DEV: 'true'. The dev blocks run twice instead. This dates from #16555, which replaced the NODE_ENV=production run of these two files with the kit-server-build project.

This sets DEV to an empty string in kit-server-build, the project that only includes these two files, so it runs their production blocks, and kit-server-dev keeps running the dev blocks.

Before, on main: 55 tests skipped in both projects (22 CSPs in prod, 33 cookies in prod). After: kit-server-build runs those 55 and skips the 8 dev ones, kit-server-dev the reverse. All pass: vitest run -c vitest.kit.config.js src/runtime/server/page/csp.spec.js src/runtime/server/cookie.spec.js gives 72 passed, 64 skipped.

On this commit, pnpm format (as oxfmt --check .), pnpm lint, the root pnpm check (which generates the types and checks every package and test app) and pnpm -F @sveltejs/kit test:unit pass (77 files, 1119 passed, 64 skipped). I didn't run the integration suites; this only changes the unit test config.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 539c0ee:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/539c0ee530ab02ffcf8ff703b1df654ce2fc37f0

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17436

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 539c0ee

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Drop the `process.env.DEV` gating, which collides with the variable Vitest
sets itself, and the separate `kit-server-build` project. Each block already
sets `__SVELTEKIT_DEV__`; the cookie spec now also mocks `esm-env`'s `DEV` so
the prod block really runs with it off.

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

@teemingc teemingc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I went with a different approach in the end just to reduce our vitest runs

@teemingc
teemingc merged commit cb758b6 into sveltejs:main Oct 21, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants