Skip to content
LogoLogo

Testing

Generated deployers only need viem clients — test the same code you ship, against an in-memory EVM, with no local node and no writes to deployments/.

@deployoor/testing

pnpm add -D @deployoor/testing vitest
import { test, expect } from "vitest";
import { createTestClients } from "@deployoor/testing";
import { getOrDeployToken } from "../deployers";
 
test("transfer moves the balance", async () => {
  const clients = await createTestClients();
  const [deployer, bob] = clients.accounts;
 
  const { contract: token } = await getOrDeployToken({
    ...clients,
    args: [deployer.address],
  });
 
  await token.write.transfer([bob.address, 1000n]);
  expect(await token.read.balanceOf([bob.address])).toBe(1000n);
});

Spreading clients passes the in-memory store, so tests never touch deployments/.

Multiple signers

const clients = await createTestClients();
const alice = clients.walletClientFor(clients.accounts[1]);

Disable plugins in tests

If your config has verifier or notifier plugins:

await getOrDeployToken({
  ...clients,
  args: [owner],
  plugins: { etherscan: false, slack: false },
});

Real node or fork

Build viem clients against anvil or a forked RPC — the deployers work unchanged. Only the store and chain differ.

Requirements

@deployoor/testing requires Node ≥ 20 (tevm dependency).