Skip to content

Algorand TypeScript Testing

Test Algorand TypeScript smart contracts quickly with an AVM-like offline runtime
npm install @algorandfoundation/algorand-typescript-testing
import { TestExecutionContext } from '@algorandfoundation/algorand-typescript-testing'
import { afterEach, describe, expect, it } from 'vitest'
import { Auction } from './contract.algo'

describe('Auction', () => {
  const ctx = new TestExecutionContext()

  afterEach(() => {
    ctx.reset()
  })

  it('updates highest bid', () => {
    const contract = ctx.contract.create(Auction)
    contract.createApplication()

    contract.auctionEnd.value = 1000
    contract.previousBid.value = 10

    const pay = ctx.any.txn.payment({
      sender: ctx.defaultSender,
      amount: 20,
    })

    contract.bid(pay)

    expect(contract.previousBid.value).toEqual(20)
    expect(contract.previousBidder.value).toEqual(ctx.defaultSender)
  })
})

Offline AVM Simulation

Execute contract logic locally with AVM-like behavior for rapid, deterministic unit tests.

TypeScript-First Testing

Use familiar test frameworks like Vitest and Jest without leaving the TypeScript workflow.

Transaction & State Helpers

Generate transactions, accounts, assets, and mock state using TestExecutionContext helpers.

Fast Feedback Loops

Validate contract behavior quickly before integration and network-level testing.