Skip to content

test(create): make path assertions cross-platform#470

Open
AboMeezO wants to merge 1 commit into
TanStack:mainfrom
AboMeezO:test/create-cross-platform-path-assertions
Open

test(create): make path assertions cross-platform#470
AboMeezO wants to merge 1 commit into
TanStack:mainfrom
AboMeezO:test/create-cross-platform-path-assertions

Conversation

@AboMeezO

@AboMeezO AboMeezO commented Jun 8, 2026

Copy link
Copy Markdown

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

  • pnpm --filter @tanstack/create test
  • pnpm --filter @tanstack/cli test
  • pnpm build

Summary by CodeRabbit

  • Tests
    • Improved test reliability with cross-platform path normalization for consistent test execution across different operating systems.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Two test files in packages/create/tests/ are updated to normalize file paths to POSIX form before comparing them. Both add a local toPosixPath helper function, update path assertions to use normalized paths, and one test corrects a type assertion from AddOn to Starter.

Changes

Cross-Platform Path Normalization in Tests

Layer / File(s) Summary
create-app test path normalization
packages/create/tests/create-app.test.ts
Added toPosixPath helper to convert Windows paths to POSIX form and imported the Starter type. Updated the "not silent" test to normalize output.files keys before comparing against resolved paths. Changed the type cast in the "with a starter" test from AddOn to Starter.
file-helper test path normalization
packages/create/tests/file-helper.test.ts
Added toPosixPath helper to normalize path separators and drive prefixes. Updated the findFilesRecursively test assertion to compare paths after mapping through the normalization helper.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Paths once twisted, now run straight and true,
Windows and Unix paths, both passing through!
With POSIX conversion, the tests shall align,
Cross-platform harmony in every line. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making path assertions cross-platform compatible by normalizing paths in test files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/create/tests/create-app.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/create/tests/create-app.test.ts

packages/create/tests/file-helper.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/create/tests/file-helper.test.ts


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/create/tests/create-app.test.ts (1)

9-11: ⚡ Quick win

Consider extracting toPosixPath to a shared test utility.

The toPosixPath helper is duplicated in both create-app.test.ts and file-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

📥 Commits

Reviewing files that changed from the base of the PR and between 6ea4076 and ab7fe6c.

📒 Files selected for processing (2)
  • packages/create/tests/create-app.test.ts
  • packages/create/tests/file-helper.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant