- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.3k
 
test(e2e-Utils): export built package from e2eUtils #5336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
          
WalkthroughReworks e2e-utils packaging and build: adds Vite build config, generates ESM/CJS outputs and d.ts files, and updates package.json exports/metadata. Adjusts an E2E React Router test to wait for domcontentloaded after URL change when reloadDocument is true. Changes
 Sequence Diagram(s)sequenceDiagram
  participant Dev as Developer/CI
  participant Vite as Vite Build
  participant Rollup as Rollup (via Vite)
  participant DTS as vite-plugin-dts
  participant Dist as dist/
  Dev->>Vite: run `vite build`
  Vite->>Rollup: bundle with SSR and preserveModules
  Rollup->>Dist: write ESM to ./dist/esm and CJS to ./dist/cjs
  Vite->>DTS: generate type declarations (entryRoot: ./src)
  DTS->>Dist: write types to ./dist/types (copy dts files)
  Dev-->>Dist: packaged artifacts ready (ESM, CJS, types)
    sequenceDiagram
  actor Tester
  participant Test as Redirect Test
  participant Page as Playwright Page
  Tester->>Test: run test with reloadDocument flag
  Test->>Page: navigate / trigger redirect
  Page-->>Test: URL changes
  Test->>Page: waitForURL(target)
  alt reloadDocument == true
    Note over Test,Page: Conditional additional wait
    Test->>Page: waitForLoadState('domcontentloaded')
  end
  Test-->>Tester: proceed with assertions
    Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
 Poem
 Pre-merge checks and finishing touches✅ Passed checks (3 passed)
 ✨ Finishing touches
 🧪 Generate unit tests
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
 🧰 Additional context used📓 Path-based instructions (3)**/package.json📄 CodeRabbit inference engine (AGENTS.md) 
 Files: 
 e2e/**📄 CodeRabbit inference engine (AGENTS.md) 
 Files: 
 **/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md) 
 Files: 
 ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
 🔇 Additional comments (8)
 Comment   | 
    
| 
           View your CI Pipeline Execution ↗ for commit 5c900ca 
 ☁️ Nx Cloud last updated this comment at   | 
    
          More templates
 
 @tanstack/arktype-adapter
 @tanstack/directive-functions-plugin
 @tanstack/eslint-plugin-router
 @tanstack/history
 @tanstack/nitro-v2-vite-plugin
 @tanstack/react-router
 @tanstack/react-router-devtools
 @tanstack/react-router-ssr-query
 @tanstack/react-start
 @tanstack/react-start-client
 @tanstack/react-start-server
 @tanstack/router-cli
 @tanstack/router-core
 @tanstack/router-devtools
 @tanstack/router-devtools-core
 @tanstack/router-generator
 @tanstack/router-plugin
 @tanstack/router-ssr-query-core
 @tanstack/router-utils
 @tanstack/router-vite-plugin
 @tanstack/server-functions-plugin
 @tanstack/solid-router
 @tanstack/solid-router-devtools
 @tanstack/solid-start
 @tanstack/solid-start-client
 @tanstack/solid-start-server
 @tanstack/start-client-core
 @tanstack/start-plugin-core
 @tanstack/start-server-core
 @tanstack/start-static-server-functions
 @tanstack/start-storage-context
 @tanstack/valibot-adapter
 @tanstack/virtual-file-routes
 @tanstack/zod-adapter
 commit:   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
e2e/e2e-utils/package.json (1)
22-23: Addfilesfield andpreparescript to e2e-utils package.json
- e2e/e2e-utils/package.json is missing a
 filesfield; add"files": ["dist"]to explicitly control published assets.- No
 prepareorprepackscript exists; include e.g."prepare": "pnpm build"underscriptsto build before publishing.dist/is already ignored globally in root.gitignore(line 13), so no further ignore changes are needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
e2e/e2e-utils/package.json(1 hunks)e2e/react-router/basic-file-based/tests/redirect.spec.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/react-router/basic-file-based/tests/redirect.spec.ts
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/react-router/basic-file-based/tests/redirect.spec.tse2e/e2e-utils/package.json
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace:* protocol for internal dependencies in package.json files
Files:
e2e/e2e-utils/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
 
🔇 Additional comments (2)
e2e/react-router/basic-file-based/tests/redirect.spec.ts (1)
67-69: LGTM! Timing fix for reloadDocument scenario.The conditional wait for
domcontentloadedwhenreloadDocumentis true ensures the page has fully loaded before proceeding with assertions. This addresses potential race conditions where the test might checkfullPageLoad(line 72) before thedomcontentloadedevent fires.e2e/e2e-utils/package.json (1)
13-16: Exports configuration is correct for dual-package (CJS + ESM).The exports properly support both CommonJS (via
require) and ESM (viaimport), with TypeScript type definitions included. This aligns with the PR objective of exporting built artifacts instead of source TS files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
♻️ Duplicate comments (1)
e2e/e2e-utils/package.json (1)
4-9: Consider adding apretestscript to ensure build runs before tests.Based on past review comments, tests may fail if the
dist/directory doesn't exist. Adding apretestscript ensures the package is built before tests run.Consider this addition:
"scripts": { "clean": "rimraf ./dist && rimraf ./coverage", "build": "vite build", + "pretest": "npm run build", "test:eslint": "eslint ./src", "test:unit": "exit 0; vitest --typecheck" },Additionally, verify that CI workflows include a build step for the
e2e-utilspackage before running tests.
🧹 Nitpick comments (1)
e2e/e2e-utils/package.json (1)
28-30: Removesrcfrom published files.The PR objective states the intent is to export built files instead of source TypeScript. Including
"src"in thefilesarray publishes the source code, which contradicts the goal and increases package size.Apply this diff:
"files": [ - "dist", - "src" + "dist" ],
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
e2e/e2e-utils/package.json(1 hunks)e2e/e2e-utils/vite.config.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/e2e-utils/vite.config.ts
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/e2e-utils/vite.config.tse2e/e2e-utils/package.json
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace:* protocol for internal dependencies in package.json files
Files:
e2e/e2e-utils/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
 - GitHub Check: Test
 
🔇 Additional comments (2)
e2e/e2e-utils/package.json (2)
6-6: Build script looks good.The
vite buildcommand correctly uses the newvite.config.tsto generate both ESM and CJS outputs with type definitions.
12-12: Alignmainfield with CJS output filename.Similar to the require export, the
mainfield should point to the actual CJS output. After fixing the require export to use.cjs, update this field as well.Apply this diff:
- "main": "dist/cjs/index.cjs", + "main": "dist/cjs/index.cjs",Note: If you fix the vite.config.ts to output
.jsinstead of.cjsfor CJS builds, then this field and the require export would be correct as-is. Choose one consistent approach.Likely an incorrect or invalid review comment.
currently we are exporting the source ts files from e2eUtils.
this is not a problem in 99% of cases but we are getting errors every now and then where the tests suites are unable to resolve the paths in the e2eUtils package.
this PR adds a built step, using tsUp, to the e2eUtils, bundling all into index.js, and updates the package exports to point to these built files.
Summary by CodeRabbit