test(create): make path assertions cross-platform#470
Conversation
📝 WalkthroughWalkthroughTwo test files in ChangesCross-Platform Path Normalization in Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/create/tests/create-app.test.tsParsing error: "parserOptions.project" has been provided for packages/create/tests/file-helper.test.tsParsing error: "parserOptions.project" has been provided for 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/create/tests/create-app.test.ts (1)
9-11: ⚡ Quick winConsider extracting
toPosixPathto a shared test utility.The
toPosixPathhelper is duplicated in bothcreate-app.test.tsandfile-helper.test.ts(lines 15-17). Extracting it to a shared test utilities file would improve maintainability.♻️ Suggested refactor
Create a new file
packages/create/tests/test-utils.ts:export function toPosixPath(path: string) { return path.replace(/\\/g, '/').replace(/^[A-Z]:/i, '') }Then import it in both test files:
+import { toPosixPath } from './test-utils.js' - -function toPosixPath(path: string) { - return path.replace(/\\/g, '/').replace(/^[A-Z]:/i, '') -}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/create/tests/create-app.test.ts` around lines 9 - 11, Extract the duplicated toPosixPath function into a single shared test utility and update tests to import it: create a new module exporting function toPosixPath(path: string) { return path.replace(/\\/g, '/').replace(/^[A-Z]:/i, '') } and replace the local definitions in create-app.test.ts and file-helper.test.ts with imports from that module; ensure the exported symbol name is exactly toPosixPath and update import statements in both test files accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/create/tests/create-app.test.ts`:
- Around line 9-11: Extract the duplicated toPosixPath function into a single
shared test utility and update tests to import it: create a new module exporting
function toPosixPath(path: string) { return path.replace(/\\/g,
'/').replace(/^[A-Z]:/i, '') } and replace the local definitions in
create-app.test.ts and file-helper.test.ts with imports from that module; ensure
the exported symbol name is exactly toPosixPath and update import statements in
both test files accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 27c78750-c231-40d9-afb9-578aaec0797f
📒 Files selected for processing (2)
packages/create/tests/create-app.test.tspackages/create/tests/file-helper.test.ts
Summary
Normalizes path-sensitive create-package test assertions so they pass on Windows as well as POSIX environments.
Why
A couple of create-package tests expected POSIX-style paths directly. On Windows, the same helpers can return drive-prefixed absolute paths with backslashes during test execution, which caused Windows-only assertion failures.
This keeps the assertions focused on the tested behavior instead of the host platform path format.
Validation
Summary by CodeRabbit