@algorandfoundation/algokit-utils 8.0.3 → 8.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,22 +63,66 @@ export interface AlgorandFixture {
63
63
  /**
64
64
  * Retrieve the current context.
65
65
  * Useful with destructuring.
66
+ *
67
+ * If you haven't called `newScope` then this will throw an error.
66
68
  * @example
67
69
  * ```typescript
68
70
  * test('My test', () => {
69
- * const {algod, indexer, testAccount, ...} = algorand.context
71
+ * const {algod, indexer, testAccount, ...} = fixture.context
70
72
  * })
71
73
  * ```
72
74
  */
73
75
  get context(): AlgorandTestAutomationContext;
74
76
  /**
75
77
  * Retrieve an `AlgorandClient` loaded with the current context, including testAccount and any generated accounts loaded as signers.
78
+ *
79
+ * If you haven't called `newScope` then this will return an `AlgorandClient` instance with no test context loaded yet and no transaction logger loaded. This is useful if you want to do some basic setup in a `beforeAll` method etc..
76
80
  */
77
81
  get algorand(): AlgorandClient;
78
82
  /**
79
- * Testing framework agnostic handler method to run before each test to prepare the `context` for that test.
83
+ * @deprecated Use newScope instead.
84
+ * Testing framework agnostic handler method to run before each test to prepare the `context` for that test with per test isolation.
80
85
  */
81
86
  beforeEach: () => Promise<void>;
87
+ /**
88
+ * Creates a new isolated fixture scope (clean transaction logger, AlgorandClient, testAccount, etc.).
89
+ *
90
+ * You can call this from any testing framework specific hook method to control when you want a new scope.
91
+ *
92
+ * @example Jest / vitest - per test isolation (beforeEach)
93
+ * ```typescript
94
+ * describe('MY MODULE', () => {
95
+ * const fixture = algorandFixture()
96
+ * beforeEach(fixture.newScope, 10_000) // Add a 10s timeout to cater for occasionally slow LocalNet calls
97
+ *
98
+ * test('MY TEST', async () => {
99
+ * const { algorand, testAccount } = fixture.context
100
+ *
101
+ * // Test stuff!
102
+ * })
103
+ * })
104
+ * ```
105
+ *
106
+ * @example Jest / vitest - test suite isolation (beforeAll)
107
+ * ```typescript
108
+ * describe('MY MODULE', () => {
109
+ * const fixture = algorandFixture()
110
+ * beforeAll(fixture.newScope, 10_000) // Add a 10s timeout to cater for occasionally slow LocalNet calls
111
+ *
112
+ * test('test1', async () => {
113
+ * const { algorand, testAccount } = fixture.context
114
+ *
115
+ * // Test stuff!
116
+ * })
117
+ * test('test2', async () => {
118
+ * const { algorand, testAccount } = fixture.context
119
+ * // algorand and testAccount are the same as in test1
120
+ * })
121
+ * })
122
+ * ```
123
+ *
124
+ */
125
+ newScope: () => Promise<void>;
82
126
  }
83
127
  /** Configuration for preparing a captured log snapshot.
84
128
  * This helps ensure that the provided configuration items won't appear