jest/async

Async Testing

Test asynchronous code

jest
async
promises

Command

it("should resolve", async () => { ... })

Explanation

Jest handles async testing with async/await and promise matchers for testing asynchronous operations.

Examples

Test async function

it("should resolve", async () => { ... })

Test promise resolution

await expect(promise).resolves.toBe(value)

Test promise rejection

await expect(promise).rejects.toThrow()