Reset the chain
anvil.reset() returns to genesis and discards every snapshot, so such files
opt out of per-test isolation:
// reset() discards every snapshot, so this suite opts out of isolation.
const node = useAnvil(
new AnvilContainer().withTestClient((client) => client.withAccount(0)),
{ isolation: "none" },
);
let deployed: Address;
it("deploys a token…", async () => {
deployed = await deployToken(node.testClient);
expect(await node.testClient.getCode({ address: deployed })).toBeDefined();
});
it("…which the next test still sees (no isolation)…", async () => {
expect(await node.testClient.getCode({ address: deployed })).toBeDefined();
});
it("…until reset() returns the node to genesis", async () => {
await node.reset();
expect(await node.testClient.getBlockNumber()).toBe(0n);
expect(
await node.testClient.getCode({ address: deployed }),
).toBeUndefined();
});
Tested in examples/test/e2e/fixtures-and-isolation.e2e.test.ts:179
- Forks re-fork at the fork block (Reset a fork).
- Back to a prepared state:
checkpoint()orloadState().