Skip to content

AlgorandFixture

Defined in: algokit-utils-ts/src/types/testing.ts:66

An Algorand automated testing fixture

beforeEach: () => Promise<void>

Defined in: algokit-utils-ts/src/types/testing.ts:90

Promise<void>


newScope: () => Promise<void>

Defined in: algokit-utils-ts/src/types/testing.ts:130

Creates a new isolated fixture scope (clean transaction logger, AlgorandClient, testAccount, etc.).

You can call this from any testing framework specific hook method to control when you want a new scope.

Promise<void>

Jest / vitest - per test isolation (beforeEach)

describe('MY MODULE', () => {
const fixture = algorandFixture()
beforeEach(fixture.newScope)
test('MY TEST', async () => {
const { algorand, testAccount } = fixture.context
// Test stuff!
})
})

Jest / vitest - test suite isolation (beforeAll)

describe('MY MODULE', () => {
const fixture = algorandFixture()
beforeAll(fixture.newScope)
test('test1', async () => {
const { algorand, testAccount } = fixture.context
// Test stuff!
})
test('test2', async () => {
const { algorand, testAccount } = fixture.context
// algorand and testAccount are the same as in test1
})
})

get algorand(): AlgorandClient

Defined in: algokit-utils-ts/src/types/testing.ts:84

Retrieve an AlgorandClient loaded with the current context, including testAccount and any generated accounts loaded as signers.

AlgorandClient


get context(): AlgorandTestAutomationContext

Defined in: algokit-utils-ts/src/types/testing.ts:79

Retrieve the current context. Useful with destructuring.

If you haven’t called newScope then this will throw an error.

test('My test', () => {
const {algod, indexer, testAccount, ...} = fixture.context
})

AlgorandTestAutomationContext