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

@hellaweb3/foundryanvil-testcontainers-nodejs

v0.7.2

Published

Fluent, type-safe Testcontainers module for Foundry Anvil: every anvil CLI flag with conflict/dependency validation, reliable startup, host/container state transfer and a chain-aware viem test client with helpers.

Readme

📖 Documentation · Quick start · Tasks · API reference · Examples

A Testcontainers module that runs a Foundry Anvil node in Docker for tests.

  • Every anvil flag through a fluent, type-safe API, validated as you set it.
  • Reliable startup that reports anvil's own errors, and host files copied in and out.
  • A pre-configured viem test client bound to the node, with anvil extras and fluent cheats.
  • Per-test isolation with useAnvil(): one node per file, restored after every test.
  • Failure diagnostics: every failing test leaves decoded reverts, traces, the pool and the node's log.
  • Gas and JSON-RPC profiling of every test, with budgets and reports.

Default image: ghcr.io/foundry-rs/foundry:v1.6.0-rc1 · Anvil reference

Installation

pnpm add -D @hellaweb3/foundryanvil-testcontainers-nodejs

Requires Node.js ≥ 22 and a Docker-compatible runtime (or none).

Quick start

A complete test file:

import {
  AnvilContainer,
  AnvilOptions,
  Hardfork,
  useAnvil,
} from "@hellaweb3/foundryanvil-testcontainers-nodejs";
import { parseEther } from "viem";

const options = new AnvilOptions().account
  .withAccounts(5)
  .withBalance(1_000) // ETH per dev account
  .evm.withChainId(1337)
  .withHardfork(Hardfork.Cancun)
  .logs.quiet();

// Starts in beforeAll, stops in afterAll, restores the state after every test.
const anvil = useAnvil(
  new AnvilContainer(options).withTestClient((client) => client.withAccount(0)),
);

it("sends Ether", async () => {
  const [, bob] = await anvil.addresses();
  // No `account` needed: dev account 0 is the typed default signer.
  const receipt = await anvil.confirm(
    anvil.testClient.sendTransaction({ to: bob, value: parseEther("1") }),
  );
  expect(receipt.status).toBe("success");
  expect(await anvil.testClient.getChainId()).toBe(1337);
});

it("manipulates the chain fluently", async () => {
  const whale = "0x1111111111111111111111111111111111111111";
  await anvil.cheats
    .setBalanceEther(whale, 1_000)
    .impersonate(whale)
    .increaseTime({ days: 7 })
    .mine();
  expect(await anvil.getBalance(whale)).toBe(parseEther("1000"));
});

Without useAnvil: const anvil = await new AnvilContainer(options).start() in beforeAll and await anvil.stop() in afterAll (lifecycle).

Documentation

The documentation site is organised by task, with a complete API reference; every code sample on it (and in this README) is a tested example.

| I want to… | Guide | |---|---| | Share a node per test file, isolate tests | Share a node · Isolate tests | | Use, fund or impersonate accounts | Accounts · Impersonate | | Send transactions, assert reverts, simulate | Send · Reverts · Simulate | | Move time, control mining | Time · Mining | | Mock contracts, save and load state | Mocks · State files | | Fork mainnet, watch events | Fork a chain · Events | | Configure the node and the client | Configure | | Find out why a test failed | Diagnose failing tests · Trace | | Profile gas and JSON-RPC calls | Gas · JSON-RPC · Budgets |

API reference: AnvilOptions · AnvilContainer · StartedAnvilContainer · test client · useAnvil · diagnostics · errors · everything.

Examples

examples/ is a separate npm project that uses this library the way your project would, with a tested workflow per topic; its workflows are the source of every code sample in the documentation.

Contributing

Scripts, the e2e suite (pnpm test:e2e, or --no-docker for local testing), the docs site (pnpm docs:start) and release steps: see CONTRIBUTING.md.

For support options, see SUPPORT.md. To report a security vulnerability privately, follow SECURITY.md. Community behavior is governed by CODE_OF_CONDUCT.md.


Maintained by Hella Labs · MIT