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

未关闭
#6,774 10 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
deno, typescript
领域
testing

调研方向

首先查看 assertEquals 文档以及 issue #6202 中链接的讨论,然后追踪当前的断言 API 及其 Blob 比较行为。确定是否可以通过返回 Promise 的异步 API 比较嵌套的 Blob 值,同时不会对现有调用方造成不可接受的影响,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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 Blobs as property values in a quite deep level of nesting?

Describe the solution you'd like

assertEquals should be able to return Promise<void> to defer such comparison.

In https://github.com/denoland/std/issues/6202#issuecomment-2498053184, @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 Blobs 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.

主要语言
TypeScript
星标
3.6k
派生
713
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

denoland/std 的其他 Issue

查看 denoland/std 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。