basarat / basarat/typescript-book

Jest async example needs an await https://basarat.gitbook.io/typescript/intro-1/jest

Open Beginner friendly
#707 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21.6k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

https://basarat.gitbook.io/typescript/intro-1/jest

Following is wrong:

```
test('basic',async () => {
expect(sum()).toBe(0);
});

test('basic again', async () => {
expect(sum(1, 2)).toBe(3);
}, 1000 /* optional timeout */);
```

You need await like:

```
test('basic', async () => {
expect(await sum()).toBe(0);
});
```

Contributor guide

Open the contributing guide

Research direction

Open the Jest example at https://basarat.gitbook.io/typescript/intro-1/jest and compare both async test snippets with the issue. Update the examples so the asynchronous sum call is awaited, and confirm the rendered page shows the corrected usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.