Async/await expresses promise-based asynchronous work in a sequential-looking form. It makes control flow easier to read without making the underlying operation synchronous. section 6.1 section 6.1.3
Compared with callback-based code, async/await offers practical testing advantages:
- Use await directly in an async test instead of combining callbacks, done(), and then(). section 6.1.3
- Treat the test more like Arrange-Act-Assert and inspect the returned value at one clear entry and exit point. section 6.1.3
- Remember that await simplifies the surface syntax; the test remains asynchronous and is still an integration test. section 6.1.3
Awaiting a website check
An async test can await a website-checking function, then assert its result: const result = await samples.isWebsiteAliveWithAsyncAwait(); expect(result.success).toBe(true); expect(result.status).toBe("ok"); section 6.1.3
Compare callback and async/await entry and exit points in the website-checking example. section 6.1
















