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

@nestjs-adk/testing

v1.0.0

Published

Testing utilities for nestjs-adk: TestAgent, scripted engine/models, Vitest matchers and LLM-as-judge.

Readme

@nestjs-adk/testing

Testing utilities for @nestjs-adk/core agents.

Testing agents is hard because the model is not deterministic. This package solves that with scripting: you tell the fake model exactly what to do, and everything else in your app runs for real, with real dependency injection and real tools. Your setup stays plain @nestjs/testing; this package only adds what is specific to agents.

npm i -D @nestjs-adk/testing

Scripting an agent

Build your testing module as usual, with ScriptedEngine as the engine. Then wrap the agent you want to script in a TestAgent:

import { AdkModule, ScriptedEngine } from "@nestjs-adk/core";
import { TestAgent } from "@nestjs-adk/testing";

const module = await Test.createTestingModule({
	imports: [AdkModule.forRoot({ engine: ScriptedEngine, defaultModel: "test-model" })],
	providers: [WeatherAgent, GetWeatherTool, WeatherService, ForecastService],
})
	.overrideProvider(WeatherService).useValue(fakeWeather) // Nest's native override
	.compile();

const weatherAgent = new TestAgent(module, WeatherAgent);

Mock calls stack turns for the next run. Nothing executes until the run happens:

weatherAgent
	.mockCallTool("get_weather", { city: "SP" })
	.mockText("It's 25°C in São Paulo.");

const run = await module.get(ForecastService).forecast("SP");

Notice the run was triggered by your own service, not by the test handle. That is the point: you test your real code path, and the script is consumed by whoever runs the agent next. When the scripted model says "call get_weather", the real tool executes through dependency injection, which proves your wiring works. There is also mockFail(message) to simulate provider errors, useful for testing failover.

Matchers

Import the matchers once in your test setup file:

import "@nestjs-adk/testing/matchers";

Then assert directly on the run result:

expect(run).toHaveCalledTool("get_weather", { city: "SP" });
expect(run).toHaveCalledToolTimes("get_weather", 1);
expect(run).toHaveCalledToolsInOrder(["get_weather"]);
expect(run).toHavePausedForApproval("refund");
expect(run).toHaveUsedAtMostTokens(1500);
expect(run).toMatchOutput(reportSchema);

Two of them deserve a note. toHaveUsedAtMostTokens turns your token budget into a regression test, so a prompt change that doubles your cost fails CI. And toBeSemanticallySimilarTo compares meaning instead of exact text, using the embedder configured in your module:

await expect(run).toBeSemanticallySimilarTo("Your order has shipped.", { threshold: 0.85 });

You can also snapshot the exact instruction the model received, which catches accidental prompt changes:

expect(weatherAgent.lastInstruction()).toMatchSnapshot();

Testing with the real engine

Sometimes you want to test the real engine loop with a scripted LLM. Use the real engine in the module and wrap the agent the same way. TestAgent registers a ScriptedModel as that agent's model override, so the native loop runs for real while the model follows your script.

Judging real outputs

For tests that talk to a real model, exact assertions do not work. The judge helper asks another LLM to evaluate the answer against a rubric:

await expectJudged(run.text).toSatisfy("Explains that the order has shipped and stays polite", { judge });

Learn more

The full documentation lives in @nestjs-adk/core and in the repository at github.com/gabrieljsilva/nestjs-adk.