AlgorandFixture
@algorandfoundation/algokit-utils / types/testing / AlgorandFixture
types/testing.AlgorandFixture
An Algorand automated testing fixture
Table of contents
Properties
Accessors
Properties
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
▸ (): Promise
<void
>
Returns
Promise
<void
>
Defined in
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
▸ (): Promise
<void
>
Returns
Promise
<void
>
Defined in
Accessors
algorand
• get
algorand(): AlgorandClient
Retrieve an AlgorandClient
loaded with the current context, including testAccount and any generated accounts loaded as signers.
Returns
Defined in
context
• get
context(): AlgorandTestAutomationContext
Retrieve the current context. Useful with destructuring.
If you haven’t called newScope
then this will throw an error.
Returns
Example
test('My test', () => { const {algod, indexer, testAccount, ...} = fixture.context})