forwardemail / forwardemail/supertest

Is it correct to say that you can't use await when you have an `expect` handler?

Open
#573 0 comments 7 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.4k
Forks
782
PR merge metrics
No merged PRs in 30d

Description

I noticed that the following code:

```
await request.put('/foo').send({}).expect(OK, (err, res) => { /* ... */)
```

Triggers a double callback bug.

I know that `expect` calls `end` if you give it a handler.
I'm guessing that `await` effectively calls `then`, which leads to the double callback.

Is this your understanding? If so, is it worth documenting this, because it took me a long time to figure out and I have a pretty strong grasp of await/async and Promises. Might be a real doozy for some less experienced folks?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.