test(e2e-rsc): migrate to playwrightModes and dynamic inferred dist#7222
Conversation
📝 WalkthroughWalkthroughThe changes enable configurable build output directories for an e2e React/RSC test suite by introducing environment variable support in Vite configuration, updating scripts to use dynamic paths, adjusting Nx test metadata, and expanding .gitignore to exclude build artifacts from multiple build tools. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 1773b3c
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@e2e/react-start/rsc/vite.config.ts`:
- Around line 6-12: The code sets outDir using nullish coalescing (const outDir
= process.env.E2E_DIST_DIR ?? 'dist'), which treats an empty string as a valid
value and can diverge from the shell start script; change the expression to use
the logical OR operator so that process.env.E2E_DIST_DIR || 'dist' is used
instead, ensuring empty strings also fall back to 'dist' (update the const
outDir initialization in vite.config.ts).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 656d486f-f301-4c0c-9c9c-2fe9f46911d0
📒 Files selected for processing (3)
e2e/react-start/rsc/.gitignoree2e/react-start/rsc/package.jsone2e/react-start/rsc/vite.config.ts
| const outDir = process.env.E2E_DIST_DIR ?? 'dist' | ||
|
|
||
| export default defineConfig({ | ||
| resolve: { tsconfigPaths: true }, | ||
| build: { | ||
| outDir, | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Confirm the config/start default semantics differ for empty E2E_DIST_DIR.
# Expected: package script uses "dist" for an empty var; the current Vite config expression would not.
node - <<'NODE'
process.env.E2E_DIST_DIR = ''
console.log('vite outDir with ??:', JSON.stringify(process.env.E2E_DIST_DIR ?? 'dist'))
console.log('vite outDir with ||:', JSON.stringify(process.env.E2E_DIST_DIR || 'dist'))
NODE
E2E_DIST_DIR='' sh -c 'printf "shell start path: %s\n" "${E2E_DIST_DIR:-dist}/server/server.js"'Repository: TanStack/router
Length of output: 150
🏁 Script executed:
# Search for E2E_DIST_DIR usage across the repository
rg "E2E_DIST_DIR" --type ts --type tsx --type json --type sh -B 2 -A 2Repository: TanStack/router
Length of output: 86
🏁 Script executed:
# Check the referenced package.json to confirm the context
fd "package.json" e2e/react-start/rsc -exec cat {} \;Repository: TanStack/router
Length of output: 205
🏁 Script executed:
# Look for other vite.config files in e2e tests to see if they have similar patterns
fd "vite.config" e2e -type f -exec cat {} \;Repository: TanStack/router
Length of output: 229
🏁 Script executed:
# Search for E2E_DIST_DIR usage across the repository
rg "E2E_DIST_DIR" -B 2 -A 2Repository: TanStack/router
Length of output: 7210
🏁 Script executed:
# Check the referenced package.json to confirm the context
cat e2e/react-start/rsc/package.jsonRepository: TanStack/router
Length of output: 1482
🏁 Script executed:
# Look for other vite.config files in e2e tests to see if they have similar patterns
find e2e -name "vite.config.ts" -o -name "vite.config.js"Repository: TanStack/router
Length of output: 5627
Use || operator to match the shell parameter expansion semantics in the start script.
Line 6 uses ?? (nullish coalescing), which treats empty strings as valid values. When E2E_DIST_DIR='', the build.outDir becomes an empty string. However, the start script in package.json line 11 uses ${E2E_DIST_DIR:-dist} (shell parameter expansion), which falls back to dist for both unset and empty values. To avoid build and start path divergence, normalize empty strings here too using the || operator.
Proposed fix
-const outDir = process.env.E2E_DIST_DIR ?? 'dist'
+const outDir = process.env.E2E_DIST_DIR || 'dist'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const outDir = process.env.E2E_DIST_DIR ?? 'dist' | |
| export default defineConfig({ | |
| resolve: { tsconfigPaths: true }, | |
| build: { | |
| outDir, | |
| }, | |
| const outDir = process.env.E2E_DIST_DIR || 'dist' | |
| export default defineConfig({ | |
| resolve: { tsconfigPaths: true }, | |
| build: { | |
| outDir, | |
| }, |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@e2e/react-start/rsc/vite.config.ts` around lines 6 - 12, The code sets outDir
using nullish coalescing (const outDir = process.env.E2E_DIST_DIR ?? 'dist'),
which treats an empty string as a valid value and can diverge from the shell
start script; change the expression to use the logical OR operator so that
process.env.E2E_DIST_DIR || 'dist' is used instead, ensuring empty strings also
fall back to 'dist' (update the const outDir initialization in vite.config.ts).
Summary
e2e/react-start/rscfrom legacynx.metadata.playwrightShardstonx.metadata.playwrightModesusing{ toolchain: \"vite\", mode: \"ssr\", shards: 6 }E2E_DIST_DIRin Vite config so inferred mode/toolchain targets build into mode-specific folders (for exampledist-vite-ssr)${E2E_DIST_DIR:-dist}and ignore inferred dist folders in.gitignoreVerification
CI=1 NX_DAEMON=false pnpm nx run tanstack-react-start-e2e-rsc:test:e2e--vite-ssr--shard-1-of-6 --outputStyle=stream --skipRemoteCachedist-vite-ssr/...and the shard target completes successfullySummary by CodeRabbit