Repository navigation
chore: run the production CSP and cookie unit tests - #17436
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/539c0ee530ab02ffcf8ff703b1df654ce2fc37f0Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
|
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
left a comment
There was a problem hiding this comment.
Nice catch. I went with a different approach in the end just to reduce our vitest runs
The
CSPs in prodblock incsp.spec.jsand thecookies in prodblock incookie.spec.jsdon't run in any project. They are skipped whenprocess.env.DEVis set, and Vitest setsprocess.env.DEVto'1'itself (it mirrorsimport.meta.env), so they are skipped inkit-server-devas well as inkit-server-build, which setsDEV: 'true'. The dev blocks run twice instead. This dates from #16555, which replaced theNODE_ENV=productionrun of these two files with thekit-server-buildproject.This sets
DEVto an empty string inkit-server-build, the project that only includes these two files, so it runs their production blocks, andkit-server-devkeeps running the dev blocks.Before, on
main: 55 tests skipped in both projects (22CSPs in prod, 33cookies in prod). After:kit-server-buildruns those 55 and skips the 8 dev ones,kit-server-devthe reverse. All pass:vitest run -c vitest.kit.config.js src/runtime/server/page/csp.spec.js src/runtime/server/cookie.spec.jsgives 72 passed, 64 skipped.On this commit,
pnpm format(asoxfmt --check .),pnpm lint, the rootpnpm check(which generates the types and checks every package and test app) andpnpm -F @sveltejs/kit test:unitpass (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:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits