@@ -200,12 +200,28 @@ declare module "cloudflare:test" {
200200 waitForStatus ( status : InstanceStatus [ "status" ] ) : Promise < void > ;
201201
202202 /**
203- * Cleans up the Workflow instance.
203+ * Cleans the Workflow instance introspector.
204+ *
204205 * This is crucial for ensuring test isolation by preventing state from
205- * leaking between tests. It's best practice to call this in an `afterEach`
206- * hook or at the end of every test.
206+ * leaking between tests. It should be called at the end or after each test.
207207 */
208208 cleanUp ( ) : Promise < void > ;
209+
210+ /**
211+ * An alias for {@link cleanUp} to support automatic disposal with the `using` keyword.
212+ * This is an alternative to calling `cleanUp()` in an `afterEach` hook.
213+ *
214+ * @see {@link cleanUp }
215+ * @example
216+ * it('my workflow test', async () => {
217+ * await using instance = await introspectWorkflowInstance(env.WORKFLOW, "123456");
218+ *
219+ * // ... your test logic ...
220+ *
221+ * // .cleanUp() is automatically called here at the end of the scope
222+ * });
223+ */
224+ [ Symbol . asyncDispose ] ( ) : Promise < void > ;
209225 }
210226
211227 /**
@@ -406,19 +422,42 @@ declare module "cloudflare:test" {
406422 * @param fn - An async callback that receives a `WorkflowInstanceModifier` object.
407423 */
408424 modifyAll ( fn : ( m : WorkflowInstanceModifier ) => Promise < void > ) : void ;
425+
409426 /**
410- * Returns all `WorkflowInstanceIntrospectors` from Workflow instances
427+ * Returns all `WorkflowInstanceIntrospector`s from Workflow instances
411428 * created after calling `introspectWorkflow`.
412429 */
413430 get ( ) : WorkflowInstanceIntrospector [ ] ;
414431
415432 /**
416- * Cleans up the Workflow introspector.
417- * This is crucial for ensuring that the introspection of a Workflow does
418- * not get persisted across tests.
419- * Call this in an `afterEach` hook or at the end of every test.
433+ *
434+ * Cleans the introspector and every `WorkflowInstanceIntrospector` from Workflow
435+ * instances created after calling `introspectWorkflow`.
436+ *
437+ * This function is essential for test isolation, ensuring that results from one
438+ * test do not leak into the next. It should be called at the end or after each test.
439+ *
440+ * **Note:** After cleanup, `introspectWorkflow()` must be called again to begin
441+ * a new introspection.
442+ *
443+ */
444+ cleanUp ( ) : Promise < void > ;
445+
446+ /**
447+ * An alias for {@link cleanUp} to support automatic disposal with the `using` keyword.
448+ * This is an alternative to calling `cleanUp()` in an `afterEach` hook.
449+ *
450+ * @see {@link cleanUp }
451+ * @example
452+ * it('my workflow test', async () => {
453+ * await using workflowIntrospector = await introspectWorkflow(env.WORKFLOW);
454+ *
455+ * // ... your test logic ...
456+ *
457+ * // .cleanUp() is automatically called here at the end of the scope
458+ * });
420459 */
421- cleanUp ( ) : void ;
460+ [ Symbol . asyncDispose ] ( ) : Promise < void > ;
422461 }
423462
424463 // Only require `params` and `data` to be specified if they're non-empty
0 commit comments