denoland / denoland/std

`assertEquals` could return `Promise` for `Blob` comparison

Open
#6,774 10 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.**

Documentation of `assertEquals` says:

> Note: When comparing `Blob` objects, you should first convert them to `Uint8Array` using the `Blob.bytes()` method and then compare their contents.

But what if one wants to compare whole objects that must contain `Blob`s as property values in a quite deep level of nesting?

**Describe the solution you'd like**

`assertEquals` should be able to return `Promise` to defer such comparison.

In , @kt3k said that changing `assertEquals` to async would be a large impact, but it seems unclear how large; the current return type of `assertEquals` is just `void`, so no one is supposed to use the return value. And of course non-async part of assertion can still be done synchronously before returning a `Promise`. Users who don't use `Blob`s wouldn't have to `await assertEquals`.

**Describe alternatives you've considered**

To write `assertEquals` for every single leaf property of the objects in concern, which is catastrophically painful.

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.