Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Incorrect prototype check

オープン
#182 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
javascript, node.js
領域
testing

調査の方向性

提供された Node の例で失敗を再現し、その後 lib/index.js の 139 行目と 239 行目付近、および comparePrototypes 設定を調査します。comparePrototypes が false の場合に、null プロトタイプのネストされたオブジェクトの比較がエラーなく成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

support
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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hapijs/code のほかの issue

hapijs/code の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。