testing

Spawn and manage isolated anvil EVM instances for vitest tests.

1|Updated Jul 22, 2025
One-click install
npx skills add https://github.com/niconiahi/ethernauta --skill testing-niconiahi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/niconiahi/ethernauta/tree/main/skills/testing
Command: npx skills add https://github.com/niconiahi/ethernauta --skill testing-niconiahi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It eliminates the pain of setting up and maintaining a consistent local Ethereum test environment by giving each test its own isolated anvil state with reliable snapshot/revert handling.

Core Features & Use Cases

  • Vitest-first lifecycle ownership: one vitest plugin line spawns an anvil process per worker and manages readiness, teardown, and isolation automatically.
  • Per-test snapshot/revert isolation: runs each test against a clean EVM state by taking and reverting snapshots around tests (unless isolation is explicitly disabled).
  • EVM RPC bindings and account helpers: exposes anvil RPC method bindings (snapshot/revert/mine/time travel) plus deterministic account derivation utilities for the spawned mnemonic.

Use case example: You’re building a dapp and want confidence that your create_reader / create_provider flow behaves correctly against a real EVM without writing custom global setup or manually cleaning state between tests.

Quick Start

Add the vitest plugin line to your vitest.config.ts and import anvil in your test file so your existing reader/provider calls run against a fresh, per-test isolated anvil instance.

Frequently Asked Questions about testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run isolated EVM tests with vitest and anvil?

To run isolated EVM tests with vitest and anvil, add the provided vitest plugin to your configuration file to automatically spawn a worker-scoped anvil process and manage its lifecycle. This setup ensures each test suite executes against a dedicated local Ethereum instance.

How does snapshot revert isolation work for local Ethereum testing?

Snapshot revert isolation works by taking an EVM snapshot before a test executes and reverting to that exact state afterward. This mechanism ensures every test runs against a clean, deterministic local chain state without needing manual cleanup or global setup teardown.

Can I use fork mode for deterministic chain state testing in vitest?

Yes, you can use fork mode for deterministic chain state testing in vitest. The Skill supports optional fork mode through env-option parsing and validation at boundaries, allowing your local anvil instance to fork off a specific network state for targeted scenario testing.

What's the best way to manage anvil RPC bindings in an EVM test suite?

The best way to manage anvil RPC bindings in an EVM test suite is importing the single root barrel API exported by the Skill. This API provides direct access to anvil RPC method bindings like snapshot, revert, mine, and time travel alongside deterministic account derivation utilities.

Why does my dapp provider integration test fail without per-test EVM cleanliness?

Your dapp provider integration test fails without per-test EVM cleanliness because residual state mutations from previous tests pollute the chain. Spawning a worker-scoped anvil instance with per-test snapshot and revert isolation guarantees the deterministic chain state required for reliable execution.