AlgorandFixture
@algorandfoundation/algokit-utils / types/testing / AlgorandFixture
types/testing.AlgorandFixture
An Algorand automated testing fixture
Table of contents
Section titled “Table of contents”Properties
Section titled “Properties”Accessors
Section titled “Accessors”Properties
Section titled “Properties”beforeEach
Section titled “beforeEach”• beforeEach: () => Promise<void>
Deprecated
Use newScope instead.
Testing framework agnostic handler method to run before each test to prepare the context for that test with per test isolation.
Type declaration
Section titled “Type declaration”▸ (): Promise<void>
Returns
Section titled “Returns”Promise<void>
Defined in
Section titled “Defined in”newScope
Section titled “newScope”• newScope: () => Promise<void>
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.
Example
describe('MY MODULE', () => { const fixture = algorandFixture(); beforeEach(fixture.newScope, 10_000); // Add a 10s timeout to cater for occasionally slow LocalNet calls
test('MY TEST', async () => { const { algorand, testAccount } = fixture.context;
// Test stuff! });});Example
describe('MY MODULE', () => { const fixture = algorandFixture(); beforeAll(fixture.newScope, 10_000); // Add a 10s timeout to cater for occasionally slow LocalNet calls
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 });});Type declaration
Section titled “Type declaration”▸ (): Promise<void>
Returns
Section titled “Returns”Promise<void>
Defined in
Section titled “Defined in”Accessors
Section titled “Accessors”algorand
Section titled “algorand”• get algorand(): AlgorandClient
Retrieve an AlgorandClient loaded with the current context, including testAccount and any generated accounts loaded as signers.
Returns
Section titled “Returns”Defined in
Section titled “Defined in”context
Section titled “context”• get context(): AlgorandTestAutomationContext
Retrieve the current context. Useful with destructuring.
If you haven’t called newScope then this will throw an error.
Returns
Section titled “Returns”Example
test('My test', () => { const {algod, indexer, testAccount, ...} = fixture.context})