Skip to content

Migration

This page is for existing users upgrading tests. If you are new to Statecraft, start with Quickstart and Core concepts.

Typed scenario context

scenario(...) now uses overloads so the final test callback’s ctx is inferred from composed built-in fixtures. You can often remove non-null assertions on publicClient, wallet, and other fields after withChain / withFork and withFundedWallet.

Custom steps should declare ScenarioStep input and output types if you want the same inference end-to-end. Untyped steps still work: they fall back to the broad ScenarioContext shape.

withErc20Balance ordering

If you omit to, TypeScript now expects a prior step that sets ctx.wallet (typically withFundedWallet). If you see a type error, reorder fixtures or pass to explicitly.

requireContext

requireContext is exported from @statecraft/vitest for runtime narrowing when you need specific keys outside the inferred pipeline.

withFundedWallet and erc20

withFundedWallet accepts an optional erc20 array to seed ERC-20 balances for the funded address using the same mechanics as withErc20Balance. Use it when the recipient is always the scenario wallet.

Suggested upgrade order

  1. Update fixtures to the current public exports from @statecraft/vitest.
  2. Re-run type checking and remove obsolete non-null assertions where inference now provides stronger context.
  3. For ERC-20 fixture errors, verify fixture order (withFundedWallet before withErc20Balance when to is omitted).