From 54e85852295aada88c1565955bf8c61cea56bdf4 Mon Sep 17 00:00:00 2001 From: Evyatar Date: Sun, 24 Sep 2023 13:23:03 +0200 Subject: [PATCH] Add docs --- website/docs/writing_tests/async_tests.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/website/docs/writing_tests/async_tests.md b/website/docs/writing_tests/async_tests.md index e1f980922..4a16e745e 100644 --- a/website/docs/writing_tests/async_tests.md +++ b/website/docs/writing_tests/async_tests.md @@ -20,3 +20,21 @@ test('name', 'Already Taken', async () => { return await doesUserExist(user); }); ``` + +## Using AbortSignal + +> Since 5.1.0 + +Each Vest test is passed as an argument an `AbortSignal` object. Vest internally sets the AbortSignal `aborted` property to true when the test is canceled. + +A test is canceled when running the same test again before its previous run has completed. + +You can use the AbortSignal to stop the execution of your async test, or pass it to your fetch request. + +[Read more on AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). + +```js +test('name', 'Already Taken', async signal => { + // ... +}); +```