Repository navigation
Add comprehensive tests for the pull request changes - #9026
Open
coderabbitai[bot] wants to merge 16 commits into
Open
coderabbitai[bot] wants to merge 16 commits into
coderabbitai[bot] wants to merge 16 commits into
Conversation
With `tanstackStart()` in a config that Vitest loads, test files are compiled as the app's code is: for the client in browser mode, jsdom and happy-dom, for the server in Node. A test run sets up no dev server, preview server or build. - A test run is the `serve` command in mode `test` with `VITEST` set. The plugins that serve or build the app are left out. - A project needs no router entry and no routes. A configured router entry still has to exist. Without one, a placeholder answers the import of the router entry, so that Start's server code loads in a server test. - The route tree is generated once, when Vitest starts, and only for a project with a router entry and a root route. Route files are never written: `Generator` takes `writeRouteFiles: false`, and an outdated or empty route file gets a warning. `tanstackRouterGenerator` and `tanStackRouterCodeSplitter` take options for a plugin that embeds them. - A route module that the generator does not know still loses `server`, `ssr` and `headers` in client code. - Vitest 5.1.1 or later: earlier versions' translation of the wildcards in `resolve.noExternal` misses Start's package names with a dash. - A browser test run pre-bundles Router Core's browser dependencies up front; Vite found them late and reloaded the page. - `@tanstack/react-start` pre-bundles `@tanstack/react-store` by a path that also resolves from a project that depends on Start only. - `scripts/e2e/run-as-installed.mjs` runs an e2e project from a `pnpm deploy` copy, where `@tanstack/*` are installed as in a user's project. `postcss` resolves to one version, so that `deploy` works. - `e2e/react-start/vitest-library` (Start only) and `vitest-app` run in browser mode, jsdom and Node, with an empty and a warm Vitest cache and as installed. They include module mocks of server functions. - Docs: a Testing guide for React Start, marked experimental. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test runs need Vitest 5.1.1 or later. `@tanstack/start-plugin-core`, `@tanstack/react-start`, `@tanstack/solid-start` and `@tanstack/vue-start` declare it as an optional peer dependency next to `vite`, so a project with an older Vitest gets a peer warning at install. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bpack and rspack The chokidar `add` listeners of the webpack and rspack plugins called the generator without the check that `watchChange` had. The check now sits in the generator call for file events, so it covers all three. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Vitest projects type-check in the workspace here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An optional peer is enforced when the package is installed, so a project with an older Vitest that never uses Start in its tests would have been asked to upgrade. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
It was pinned to 5.1.1 next to a `vitest` from the catalog, so the two would have drifted apart on the next Vitest bump. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…roject with Start only `@tanstack/vue-router > @tanstack/vue-store` only resolves from a project that depends on the router. Vite warned, found the store late and reloaded the page. The integration harness takes the framework of the app for the regression test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s-installed Node joins the arguments of a shell command without quoting them, so a temporary directory with a space in its path broke `pnpm deploy`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…dule cache In client code Start serves a route tree without the routes that only the server uses, built from all route files. Vitest keys a cached module by its own file, and the generated route tree lists every route: when a route got its first client option, jsdom and happy-dom tests kept the route tree of an earlier run without that route, until the cache was cleared. The plugin's `configureVitest` hook now excludes the module from the cache. The integration test runs the Vitest CLI twice on a temporary app. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…op the Router Core pre-bundle list The list of Router Core's dependencies in the test-run config only served the run of `vitest-app` inside this repository, where Start's packages are links and Vite finds what they import late. In an installed project Vite pre-bundles nothing late, with or without the list. Both projects now run their tests only in the installed copy, twice: with an empty Vitest cache and from the warm cache. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n in place fails Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- One entry plan: a test run makes the router entry optional through an option, and an absent entry is an empty string everywhere. - `excludeFromTestRuns` only wraps the dev server plugins. The post-build, preview and dev client entry plugins have no hook a test run calls. - The client route tree plugin tests a module id in one place. - An unknown route module that names no route option to delete is not parsed. - The integration harness takes options instead of positional arguments. - `run-as-installed.mjs` runs a script of the project. - Removed: tests of the generator's host options under webpack and rspack, which no entry point can pass them to, and the Vitest cache path of the e2e projects, which is the default in the installed copy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…o root route lookup The plugin that embeds the route generator passes one function that gets the generator's config and returns `enabled`, `watch` and `writeRouteFiles`, instead of three callbacks. In a test run Start generates a route tree for a project with a router entry and a routes directory (or a virtual route config). It no longer looks for the root route file itself, which repeated a part of the generator's rules. A project with a routes directory and no root route now gets the generator's error, as in the dev server. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ernal code splitting option `deleteNodesInUnknownRoutes` is a field of `codeSplittingOptions` marked `@internal`, which `stripInternal` leaves out of the published types. The code splitter no longer takes host options as a fourth argument, and `tanStackRouterCodeSplitter` has its two arguments again. Start sets the field with a type assertion, since it compiles against the published types. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The dev server plugin installed no middleware when Vite's mode was `test`, so `vite dev --mode test` answered "404 Cannot GET /". The check kept Start's dev middleware out of a Vitest server. A Vitest run now leaves the dev server plugins out as a whole, so the check only broke the dev server. Same change as #8654, #5181 and #4642. Fixes #4620 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…mode <!-- coderabbit-ai-generated:v1 -->
🦋 Changeset detectedLatest commit: ff16bbf The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Author
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.
|
This branch has not been deployed
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.
Verified that the checkout matches PR #8965 at
b09ccd2613. Added four regression tests covering:vite dev --mode testoutside Vitest.All 28 tests in the scoped runs passed, including the four new cases. Formatting and whitespace checks passed. Only the four test files changed; nothing was committed, pushed, or posted.
View coding task