denoland / denoland/std

Support the Response object in assertObjectMatch

Open
#2,204 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

I'm creating some tests for a server handler, and assertObjectMatch didn't work as expected on the responses.

**Describe the solution you'd like**

That

```
assertObjectMatch(new Response(), { status: 200 });
assertObjectMatch(new Response(null, { status: 400, statusText: "Not Found" }), { status: 400, statusText: "Not Found" });
```

would work.

**Describe alternatives you've considered**

The Response object does not have enumerable properties, so there's no elegant way to convert it into a plain object.

An alternative is to map the values manually:

```
const response = new Response()

assertObjectMatch(
{
status: response.status
},
{
status: 200
}
)
```

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.