@gojob/wait-for-assertion
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@gojob/wait-for-assertion", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Wait for asynchronous testing assertions", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/gojob-1337/wait-for-assertion.git", |
@@ -12,1 +12,22 @@ # Wait for Assertion | ||
``` | ||
## Example | ||
```typescript | ||
import { waitForAssertion } from '@gojob/wait-for-assertion'; | ||
// [...] | ||
it('should asynchronously update the value in Elasticsearch', async () => { | ||
await request(server) | ||
.put(endpointURL) | ||
.send(input) | ||
.expect(HttpStatus.NO_CONTENT); | ||
// this would fail directly, if not awaited, as the document is not immediatly available in Elasticsearch | ||
await waitForAssertion(async () => { | ||
const { document } = await elasticsearchService.get(UserIndex, userId); | ||
return expect(document.firstName).toBe(updatedUser.firstName); | ||
}); | ||
}); | ||
``` |
6132
32