test: cover the SSR and "use client" guarantees - #57
Open
sidgaikwad wants to merge 1 commit into
Open
Conversation
The README states the component works in React Server Components environments, and that it touches the DOM only inside effects. Nothing verified either claim: the whole suite runs in jsdom, and the 'use client' banner is a tsup config detail that a bundler or config change could silently drop with every existing test still passing. Add test/ssr.test.tsx, which runs with `@vitest-environment node`: - asserts there really is no DOM in that environment, so the rest of the file proves something - renders the component with renderToString, bare and with every prop set - asserts both built bundles start with 'use client' The dist assertion is skipped when dist/ is absent, so it runs in the CI job that builds first and does not fail the Node/React matrix jobs.
|
@sidgaikwad is attempting to deploy a commit to the Unlayer Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
Also, the matrix jobs do build: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #41.
The README makes two promises that nothing verified:
The whole suite runs in
jsdom, so every test renders client-side, and the'use client'banner is atsupconfig detail — a bundler or config change could drop it and every existing test would still pass.New
test/ssr.test.tsx, running with@vitest-environment noderenderToStringthe component, bare and again with every prop set. Effects don't run on the server, so a prop that reached the DOM during render rather than in an effect would throw here.'use client';.Verification
The banner assertion is not decorative — I deleted the
bannerline fromtsup.config.ts, rebuilt, and it failed:It also skips cleanly rather than failing when
dist/is absent:That matters because the
checksCI job runsnpm run buildbefore the tests (so it executes there), while the Node/React matrix jobs runnpm testwithout building (so it skips).lint,typecheckclean