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

@nl-framework/testing

v0.5.1

Published

First-party testing utilities for nl-framework: testing module builder with provider/guard/interceptor/filter overrides, plus in-process HTTP, GraphQL, and microservice harnesses.

Readme

@nl-framework/testing

First-party testing utilities for the NL Framework, mirroring @nestjs/testing ergonomics. Build an application context with overridable providers, then drive HTTP, GraphQL, and microservice handlers in-process — no port binding, no Mongo, no Dapr, no network.

Installation

bun add -d @nl-framework/testing

@nl-framework/core is a required peer. @nl-framework/http, @nl-framework/graphql, and @nl-framework/microservices are optional peers — you only need the ones whose transport you test (they are loaded lazily).

The testing module

Test.createTestingModule() builds an ApplicationContext in which overrides are registered before any provider is instantiated, so every dependent receives the substitute rather than the original.

import { Test } from '@nl-framework/testing';

const moduleRef = await Test.createTestingModule({
  imports: [AppModule],
  providers: [/* extra providers */],
})
  .overrideProvider(UserService).useValue(mockUserService)
  .overrideProvider(CONFIG_TOKEN).useFactory({ factory: () => testConfig })
  .overrideGuard(AuthGuard).useValue({ canActivate: () => true })
  .overrideInterceptor(CacheInterceptor).useValue(passthroughInterceptor)
  .overrideFilter(HttpExceptionFilter).useClass(TestFilter)
  .compile();

const service = await moduleRef.get(UserService);

// ...assertions...

await moduleRef.close(); // runs the shutdown lifecycle (onModuleDestroy)

Guards, interceptors, filters, and pipes all resolve through the container at runtime, so overrideGuard/overrideInterceptor/overrideFilter/overridePipe are token swaps handled by the same mechanism as overrideProvider.

Each override terminal supports .useValue(v), .useClass(C), and .useFactory({ factory, inject? }).

HTTP

No port is bound — requests go straight through HttpApplication.handle.

const app = await moduleRef.createHttpApplication();

const res = await app.request('/users/42', { headers: { 'x-token': 'secret' } });
// res is a standard Response

const { status, body } = await app.requestJson('/users', {
  method: 'POST',
  json: { name: 'Grace' }, // serialized, content-type defaulted to application/json
});

GraphQL

Executes via Apollo's executeOperation, with the framework's scoped container resolver attached so guards and interceptors run exactly as they would over HTTP.

const gql = await moduleRef.createGraphqlApplication();

const { data, errors } = await gql.execute<{ report: { message: string } }>({
  query: /* GraphQL */ `query ($score: Int!) { report(score: $score) { message } }`,
  variables: { score: 7 },
});

The GraphQL schema metadata is a process-global singleton. If you declare types at module scope across several test files, reset it between cases with GraphqlMetadataStorage.get().clear() (and clearGraphqlGuards() / clearGraphqlInterceptors() if you register global ones).

Microservices

Drives MessageDispatcher through an in-memory transport — no Dapr sidecar.

const harness = await moduleRef.createMicroserviceHarness();
// defaults to the module's discovered controllers; pass { controllers: [...] } to scope it

const result = await harness.send<number>('math.double', { value: 21 }); // 42
await harness.emit('math.logged', { value: 5 }); // fire-and-forget event

InMemoryTransport is also exported directly, e.g. to wire into createMicroservicesModule({ transport }).

Repositories (ORM)

InMemoryRepository<T> is a dependency-free, in-memory implementation of the full OrmRepository contract — find / findOne / findById / count / insertOne / insertMany / save / updateMany / softDelete / restore / deleteHard / deleteMany. It mirrors MongoRepository's behavior: string id + _id assignment, timestamps, and softDelete semantics, with a Mongo-style filter matcher ($and / $or / $in / $exists / $gt…$lte / $regex, dot paths). No real MongoDB, no mongodb-memory-server.

import { InMemoryRepository, createInMemoryRepository } from '@nl-framework/testing';
import { getRepositoryToken } from '@nl-framework/orm';

// Direct construction (defaults timestamps + softDelete to true, like @Document):
const repo = new InMemoryRepository(User, {
  seed: [{ name: 'Ada', age: 36 }],
});

// Or read timestamps/softDelete/collection straight from the entity's @Document:
const repo2 = await createInMemoryRepository(User, { seed: [/* ... */] });

const moduleRef = await Test.createTestingModule({ imports: [AppModule] })
  .overrideProvider(getRepositoryToken(User))
  .useValue(repo)
  .compile();

Extra test conveniences: repo.snapshot() (isolated clones of all docs), repo.size, and repo.clear(). The fake does not emit write-notifier events.

@nl-framework/orm is an optional peer. InMemoryRepository's constructor has no ORM runtime dependency; only createInMemoryRepository (which reads @Document metadata) lazily imports the ORM.

License

Apache-2.0