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

@rudderjs/testing

v0.0.8

Published

Integration testing utilities for RudderJS applications — `TestCase` base class, fluent `TestResponse` assertions, and reusable traits.

Downloads

1,025

Readme

@rudderjs/testing

Integration testing utilities for RudderJS applications — TestCase base class, fluent TestResponse assertions, and reusable traits.

Installation

pnpm add -D @rudderjs/testing

Setup

Extend TestCase and override providers() and config() to bootstrap your application for testing.

import { describe, it, afterEach } from 'node:test'
import { TestCase, RefreshDatabase } from '@rudderjs/testing'
import { DatabaseProvider } from '@rudderjs/orm'
import { AuthProvider } from '@rudderjs/auth'

class AppTest extends TestCase {
  use = [RefreshDatabase]

  protected providers() {
    return [DatabaseProvider, AuthProvider]
  }

  protected config() {
    return { database: { url: 'file:./test.db' } }
  }
}

describe('Users API', () => {
  let t: AppTest
  afterEach(() => t.teardown())

  it('lists users', async () => {
    t = await AppTest.create()
    const response = await t.get('/api/users')
    response.assertOk()
    response.assertJsonStructure(['data'])
  })
})

HTTP Request Helpers

TestCase provides helpers that send requests through your application's fetch handler without a running server:

await t.get('/api/users')
await t.post('/api/users', { name: 'Alice' })
await t.put('/api/users/1', { name: 'Bob' })
await t.patch('/api/users/1', { active: true })
await t.delete('/api/users/1')

Authenticated Requests

const response = await t
  .actingAs({ id: '1', email: '[email protected]' })
  .get('/api/admin/dashboard')

response.assertOk()

TestResponse Assertions

| Method | Description | |--------|-------------| | assertStatus(code) | Exact status code match | | assertOk() | Status 200 | | assertCreated() | Status 201 | | assertNoContent() | Status 204 | | assertNotFound() | Status 404 | | assertForbidden() | Status 403 | | assertUnauthorized() | Status 401 | | assertUnprocessable() | Status 422 | | assertSuccessful() | Status 2xx | | assertServerError() | Status 5xx | | assertJson({ key: value }) | Partial JSON body match | | assertJsonPath('data.0.name', 'Alice') | Dot-path value match | | assertJsonCount(3, 'data') | Array length at path | | assertJsonStructure(['id', 'name']) | Keys present in body | | assertJsonMissing({ secret: '...' }) | Keys/values absent | | assertHeader('Content-Type', 'json') | Header present (contains) | | assertHeaderMissing('X-Debug') | Header absent | | assertRedirect('/login') | 3xx with Location header |

Database Assertions

await t.assertDatabaseHas('users', { email: '[email protected]' })
await t.assertDatabaseMissing('users', { email: '[email protected]' })
await t.assertDatabaseCount('users', 5)
await t.assertDatabaseEmpty('sessions')

Traits

RefreshDatabase

Truncates all database tables before each test for isolation.

class MyTest extends TestCase {
  use = [RefreshDatabase]
}

WithFaker

Injects a @faker-js/faker instance for generating test data. Requires @faker-js/faker as a peer dependency.

import { WithFaker } from '@rudderjs/testing'

class MyTest extends TestCase {
  use = [WithFaker]
}

const t = await MyTest.create()
const name = t.faker.person.fullName()
const email = t.faker.internet.email()

Notes

  • Uses Node.js native assert/strict under the hood — no external test framework dependency.
  • TestCase.create() bootstraps the application in testing mode with debug: true.
  • Database assertions require an ORM adapter registered via providers.
  • HTTP helpers require a server adapter that binds a fetchHandler in the container.