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

convex-test-provider

v0.2.0

Published

React provider that adapts convex-test's one-shot client for use with ConvexProvider, so useQuery/useMutation work in tests.

Readme

convex-test-provider

React provider that adapts convex-test's one-shot query/mutation client for use with Convex's ConvexProvider, so useQuery and useMutation work in tests against an in-memory backend.

Install

npm i convex convex-test react
npm i -D convex-test-provider

Usage

  1. Create a convex-test client: convexTest(schema, modules).
  2. Wrap your component with ConvexTestProvider and pass the client:
import { convexTest } from "convex-test";
import { ConvexTestProvider } from "convex-test-provider";
import schema from "./convex/schema";
import { modules } from "./convex/test.setup";

const testClient = convexTest(schema, modules);

render(
  <ConvexTestProvider client={testClient}>
    <YourComponent />
  </ConvexTestProvider>
);

Query reactivity

This adapter runs each query once (when the component mounts). The UI does not re-render after a mutation in the same test. Assert backend state via client.query(api.your.list, {}), or re-mount to run the query again.

Helper Functions

Reduce test boilerplate from ~15 lines to ~2 lines with createConvexTest.

Setup

Create a test setup file in your Convex directory:

// convex/test.setup.ts
import { createConvexTest, renderWithConvex } from "convex-test-provider";
import schema from "./schema";

export const modules = import.meta.glob("./**/!(*.*.*)*.*s");
export const test = createConvexTest(schema, modules);
export { renderWithConvex };

Usage

// src/components/TodoList.test.tsx
import { test, renderWithConvex } from "../../convex/test.setup";
import { expect } from "vitest";
import { api } from "../../convex/_generated/api";

test("creates a todo", async ({ client, seed }) => {
  await seed("todos", { text: "Buy milk", completed: false });

  const todos = await client.query(api.todos.list, {});
  expect(todos).toHaveLength(1);
});

Fixtures

| Fixture | Description | |---------|-------------| | testClient | Raw convex-test client (unauthenticated) | | userId | Current user's ID (user auto-created) | | client | Authenticated client for the current user | | seed(table, data) | Insert data, auto-fills userId field | | createUser() | Create another authenticated user |

Multi-user Test Example

test("users only see their own todos", async ({ client, createUser }) => {
  // Alice creates a todo
  await client.mutation(api.todos.create, { text: "Alice's todo" });

  // Bob can't see Alice's todo
  const bob = await createUser();
  const bobTodos = await bob.query(api.todos.list, {});
  expect(bobTodos).toHaveLength(0);
});

Configuration

// Custom users table name
export const test = createConvexTest(schema, modules, {
  usersTable: "profiles",
});

Additional Helpers

  • wrapWithConvex(children, client) — JSX wrapper for custom rendering
  • renderWithConvex(ui, client) — Testing Library render with Convex provider

Types

The client prop accepts any object with query(ref, args) and mutation(ref, args) returning promises. The result of convexTest(schema, modules) (and .withIdentity(...)) satisfies this.

Contributing

See CONTRIBUTING.md for the development workflow.

AI agents: See CLAUDE.md for quick reference.

Versioning

Releases follow semantic versioning. See CHANGELOG.md for release history.