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

@wisemen/nestjs-tests

v3.0.0

Published

Testing helpers for NestJS API packages, with custom `expect` matchers and a stubbed TypeORM `DataSource` for transaction-based unit tests.

Readme

@wisemen/nestjs-tests

Testing helpers for NestJS API packages, with custom expect matchers and a stubbed TypeORM DataSource for transaction-based unit tests.

Installation

pnpm add -D @wisemen/nestjs-tests

Peer dependencies

pnpm add -D @wisemen/nestjs-domain-events typeorm

Usage

Register the matchers once

import { expect } from 'expect'
import {
  ISO8601,
  isEnumValue,
  toHaveEmitted,
  toHaveErrorCode,
  toHaveStatus,
  toHaveValidationErrors,
  uuid,
} from '@wisemen/nestjs-tests'

expect.extend({
  ISO8601,
  isEnumValue,
  toHaveEmitted,
  toHaveErrorCode,
  toHaveStatus,
  toHaveValidationErrors,
  uuid,
})

Assert HTTP responses and DTO validation

import { HttpStatus } from '@nestjs/common'

expect(response).toHaveStatus(HttpStatus.CREATED)
expect(response).toHaveErrorCode('validation_error')

expect(response.body).toStrictEqual(expect.objectContaining({
  uuid: expect.uuid(),
  createdAt: expect.ISO8601(),
}))

await expect(command).toHaveValidationErrors()
expect(role).isEnumValue(UserRole)

Stub transactional use cases

stubDataSource() creates a Sinon stub for DataSource and executes transaction(...) callbacks with a stubbed EntityManager.

import { createStubInstance } from 'sinon'
import { DomainEventEmitter } from '@wisemen/nestjs-domain-events'
import { stubDataSource } from '@wisemen/nestjs-tests'

const eventEmitter = createStubInstance(DomainEventEmitter)
const useCase = new CreateOrderUseCase(
  stubDataSource(),
  createStubInstance(OrderRepository),
  eventEmitter,
)

const response = await useCase.execute(command)

expect(eventEmitter).toHaveEmitted(new OrderCreatedEvent(response.uuid))

License

GPL

Parallel test runner

The package includes a CLI for running compiled Node test files in a fixed number of long-lived processes. Each process runs its assigned files with Node test isolation disabled, allowing a test bench to reuse setup within that process while keeping process state separate from other workers.

pnpm exec nestjs-tests-parallel \
  --env-file=.env.test \
  --workers=2 \
  --test="dist/src/**/*.test.js" \
  --global-setup=dist/src/modules/test-setup/global-setup.js

--workers defaults to 2. --test defaults to dist/src/**/*.test.js, so the glob includes both the build directory and test file pattern. --global-setup defaults to the path shown above. The global setup module must export an async or sync globalSetup function. --env-file is optional; when provided, the CLI loads it before global setup and passes the resulting environment to each test process. The runner sets generic TEST_RUN_ID and TEST_WORKER_IDS environment variables for global setup, then assigns each child process its one-based TEST_WORKER_ID. Use getTestRunId(), getTestWorkerIds(), and getTestWorkerId() from this package to read them. These helpers return undefined when a value is not configured and reject malformed IDs. A global setup can use the run ID and worker IDs to provision per-worker resources. If the setup module exports globalTeardown, the runner calls it after all workers finish, including when global setup fails.