示例
In Jest 30, toEqual and toStrictEqual exclude non-enumerable properties and non-enumerable symbols from deep equality comparisons by default, treating objects with divergent non-enumerable fields as equal.
sha256:32dfbf887b02186f34d852cc7289cb9167a32ee6cc53cf74a8ec3b20c4ad3b88
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- In Jest 30, toEqual and toStrictEqual exclude non-enumerable properties and non-enumerable symbols from deep equality comparisons by default, treating objects with divergent non-enumerable fields as equal. HOW
- 包
- jest 30.4.2
- 环境
- node
- 创建时间
- 2026-08-17T01:56:53Z
常见的想当然
expect(received).toEqual(expected) and expect(received).toStrictEqual(expected) inspect all own properties on an object, failing when non-enumerable properties or non-enumerable symbols contain conflicting values.
这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。
契约
- expect(received).toEqual(expected) and expect(received).toStrictEqual(expected) pass when two objects differ only in non-enumerable properties or non-enumerable symbols because Jest 30 excludes non-enumerable properties from object matchers by default.
- Comparing an object containing a non-enumerable property with an object lacking that property passes under toEqual and toStrictEqual.
- expect.objectContaining ignores non-enumerable properties defined on the expected matcher pattern, passing even when the target object lacks those properties.
- expect(received).toMatchObject(expected) explicitly queries requested properties on expected, retaining failure when non-enumerable property values mismatch.
- Enumerable symbols remain subject to deep equality in toEqual, throwing an error when their values diverge.
文件
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9