0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00

Compare commits

..

3 commits

Author SHA1 Message Date
Manuel Schiller
8665a8edfa test(e2e): fail the installed run when a Start package is still linked
`run-as-installed.mjs` now checks, before it runs the command, that every
`@tanstack/*` dependency of the project resolves to a package inside the
`pnpm deploy` copy. If a change to pnpm's settings or to `deploy` left a
link into `packages/*`, the run would test the linked workspace again and
still pass. `run-as-installed.md` says how the run is part of CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 17:45:56 +01:00
Manuel Schiller
e2340871e8 fix(start): pre-bundle Router Core's browser deps in test runs, wait for the callback in runInRequest
- A browser test run found `cookie-es`, `seroval` and
  `seroval-plugins/web` only when a test imported them, because Start's
  packages are not pre-bundled and Vite's start-up scan does not look
  into them. Vite then pre-bundled them and reloaded the page, and in CI
  a test iframe did not start ("did not become ready within 60000ms").
  The test-run plan now includes them by a path from the Start package.
- `runInRequest` resolved before the callback had finished when a
  request middleware did not wait for `next()`, and reported that the
  middleware had ended the request. It now keeps the callback's promise
  and always waits for it. That replaces two flags.
- The generator test compared route file paths built with `path.join`,
  which fails on Windows: the generator names them with forward slashes.
- Simpler: the mock registries register their maps with the setup file
  instead of a snapshot function each, the client function of a
  middleware is wrapped only when it has one, and the scope no longer
  carries a handler type that was always `router`.
- Docs: tests that run concurrently share the mocks registered outside
  `runInRequest`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 17:39:12 +01:00
Manuel Schiller
6ddaed9f70 feat(start): experimental Vitest support and typed test helpers
- 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 project needs no router entry and
  no routes. The route tree is generated once, and route files are never
  written.
- `mockServerFn` and `resetServerFnMocks` in `<framework>-start/testing`:
  in a client test a server function call goes to a mock that is typed
  from the function, in place of a request.
- `runInRequest`, `mockMiddleware` and `runMiddleware` in
  `<framework>-start/testing/server`: a server test runs server functions
  and middleware for a request it describes.
- Mocks end with the test that registered them. The plugin adds a setup
  file to every Vitest project for that.
- In a test run the server finds a server function by its id alone.
  Vitest serves compiled modules from its cache from the second run on,
  so the compiler has no record of them.
- In a test run Start names its packages in `resolve.noExternal` with
  regular expressions. Vitest's translation of the wildcards does not
  match a `-`, so jsdom and Node tests of an installed project ran
  `@tanstack/start-client-core` uncompiled.
- `@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 in `node_modules` as in a
  user's project.
- `e2e/react-start/vitest-library` and `e2e/react-start/vitest-app` run
  their tests with an empty Vitest cache, from the warm cache and as an
  installed project.
- Docs: `docs/start/framework/react/guide/testing.md`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-15 17:10:33 +01:00
117 changed files with 6754 additions and 147 deletions

Some files were not shown because too many files have changed in this diff Show more