forwardemail / forwardemail/supertest

Using jest.expect

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

Description

Hi folks,

I love supertest but I got annoyed by simple assert messages like
```
expected { products: [ { de: [Object], en: [Object] } ] } response body, got { products: [ { de: [Object], en: [Object] } ] }
```

As a quick fix, I often override _assertBody:
```js
const request = require("supertest");

request.Test.prototype._assertBody = (body, res) => {
expect(res.body).toEqual(body);
};
```

This works fine but with 3 restrictions:
- relies on specific assert-implementation e.g. jest
- only works for the body
- only works if request can be match at all

I'd like to see sth like this build into supertest. Before I create a PR, I thought to discuss this. Also, happy for ideas working around mentioned restrictions ;)

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.