Incorrect prototype check
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 38/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript, node.js
- 領域
- testing
研究方向
使用提供的 Node 範例重現此故障,然後檢查 lib/index.js 第 139 行和第 239 行附近的程式碼,以及 comparePrototypes 設定。當 comparePrototypes 為 false 時,巢狀的 null 原型物件能夠在不發生錯誤的情況下完成比較,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Support plan
- is this issue currently blocking your project? yes
- is this issue affecting a production system? no
Context
- node version: 18.x
- module version with issue: 9.0.3
- last module version without issue: NA
- environment (e.g. node, browser, native): node
- used with
@hapi/[email protected] - any other relevant information: NA
What are you trying to achieve or the steps to reproduce?
The module does not ignore the prototype during a comparison.
const Code = require('@hapi/code');
const noProto = Object.create(null);
noProto.a = Object.create(null);
noProto.a.b = 1;
Code.settings.comparePrototypes = false;
Code.expect([noProto]).to.once.include({ a: { b: 1 } });
** By using simple objects {} the comparison works as expected.
What was the result you got?
/Users/manuel_spigolon/dev/misc/hapi/code/lib/index.js:139
throw error;
^
Error: Expected [ [Object: null prototype] { a: [Object: null prototype] { b: 1 } } ] to include { a: { b: 1 } } once
at internals.Assertion.internals.include (/Users/manuel_spigolon/dev/misc/hapi/code/lib/index.js:239:17)
at Object.<anonymous> (/Users/manuel_spigolon/dev/misc/hapi/code/asd.js:8:32)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47 {
actual: undefined,
expected: undefined,
}
What result did you expect?
No error due to the default comparePrototypes = false setting
- 主要語言
- JavaScript
- 星號
- 231
- 分支
- 75
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
hapijs/code 的其他 Issue
-
feature
難度 5/5 一週以上 新手友好度 30/100
-
feature
難度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 65/100
NaturalIntelligence/fast-xml-parser#888 · 1 則留言 ·
維護者通常 2 天內回覆
-
bug callouts regression revealjs
難度 2/5 1-3 小時 新手友好度 72/100
quarto-dev/quarto-cli#15014 ·
維護者通常 1 天內回覆
-
check:passed feeds:remove
難度 1/5 1 小時以內 新手友好度 65/100
iptv-org/database#37176 · 1 則留言 · 1 個 reaction ·
維護者通常 9 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
hawk-digital-environments/HAWKI#443 ·
維護者通常 1 天內回覆
-
documentation v2
難度 2/5 1-3 小時 新手友好度 82/100
modelcontextprotocol/python-sdk#3662 ·
維護者通常 1 天內回覆