npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tanstack-router-testing/react-start-testing

v0.4.0

Published

Upstream-shaped test helpers for @tanstack/react-start: direct server function tests, mocks, env control, and Vitest wiring.

Readme

tanstack-router-testing

Unit testing utilities for TanStack Router and TanStack Start.

Quick start

pnpm add -D @tanstack-router-testing/react-router-testing @tanstack-router-testing/react-start-testing

Configure Vitest with the Start shim:

// vitest.config.ts
import { tanstackStartTesting } from '@tanstack-router-testing/react-start-testing/vite';
import { defineConfig } from 'vitest/config';

export default defineConfig({
  plugins: [tanstackStartTesting()],
  test: { environment: 'jsdom' },
});

Write your first test — import a single route file, pass it to the harness, and assert:

// posts.$postId.test.tsx
import { render } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { createRouterHarness } from '@tanstack-router-testing/react-router-testing';
import { Route } from './routes/posts.$postId';

describe('post route', () => {
  it('loads and renders a post', async () => {
    const harness = createRouterHarness({
      route: Route,
      params: { postId: '42' }, // fully typed from route path
      loaderData: { id: '42', title: 'Hello' }, // skip the real loader
    });
    await harness.load();
    const { findByText } = render(<harness.TestRouterProvider />);
    await expect(findByText('Hello')).resolves.toBeTruthy();
    harness.cleanup();
  });
});

Or use a full route tree for integration-level tests:

import { createRouterHarness } from '@tanstack-router-testing/react-router-testing';
import { routeTree } from './routeTree.gen';

const harness = createRouterHarness({ routeTree, initialEntries: ['/posts/7'] });
await harness.load();
expect(harness.getLoaderData('/posts/$postId')).toBeDefined();
harness.cleanup();

Packages

| Package | Purpose | | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | react-router-testing | createRouterHarness (file route or full tree), createTestRouter, SSR harness | | react-start-testing | mockServerFn, mockMiddleware, createStartTestRuntime, RSC runtime, Vite plugin | | router-testing-core | Internal registry/env runtime (transitive dependency) | | react-start-testing-storybook | Storybook decorator for Start stories |

All packages are scoped under @tanstack-router-testing/.

Design principles

  1. Real router, not route stubs. Tests exercise createRouter, route trees, memory history, loaders, guards, params, search, and redirects through the router itself.
  2. Production-shaped Start calls. Server functions are called as await fn({ data }) — the harness supplies mocks and leaves the call shape alone.
  3. Upstream-mergeable shape. Public exports are shaped for future first-party subpaths (@tanstack/react-router/testing).

Documentation

Running tests

pnpm run build              # build all packages
pnpm test:unit:core         # fast core + integration tests
pnpm test:types             # type-level assertions
pnpm test:unit:vendored     # 110 vendored TanStack app smoke tests
pnpm run lint:check         # oxlint + oxfmt

Contributing

This project aims to become an upstream contribution to tanstack/router. Feedback, issues, and PRs welcome.

License

MIT