denoland / denoland/std

`@std/assert/equals` considers `Object.create(null)` and `{}` to be equal

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

Description

**Describe the bug**
- Since https://github.com/denoland/std/pull/6153, `assertEquals` checks object prototypes. However, it makes certain exceptions to keep existing tests within the repo from failing.
- Other assertion libraries have more correct checks: `"node:assert/strict"`, `"ava"`, and `"uvu"` all make a distinction between null-prototype object and plain objects. `"node:assert"` and `"chai"` don't.

**Steps to Reproduce**
The following assertion passes:
```ts
import { assertEquals } from "@std/assert"
assertEquals(Object.create(Object.prototype), Object.create(null))
```

**Expected behavior**
The assertion fails.

**Environment**
Not applicable.

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.