test.deepEqual gives AssertionError, without actual saying what property is not equal
- 主要言語
- JavaScript
- スター
- 1.9k
- フォーク
- 359
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
When test.deepEqual fails, we get a generic "AssertionError" message, without stating what property was mismatched. This requires you to scan the two objects to see what fails.
For example, I am trying a deepEqual test on two mongo schemas that seem to be exactly the same:
var mongoose = require('mongoose'),
ObjectId = mongoose.Schema.ObjectId;
module.exports = {
'deep equals works for mongooose schemas' : function(test){
// SETUP/TEST
var schemaA = new mongoose.Schema({keyA : String, keyB : ObjectId});
var schemaB = new mongoose.Schema({keyA : String, keyB : ObjectId});
// ASSERT
test.deepEqual(schemaA, schemaB);
test.done();
}
};
This gives me the following error when running the test:
✖ deep equals works for mongooose schemas
AssertionError:
{ paths:
{ keyA:
{ enumValues: [],
regExp: null,
path: 'keyA',
instance: 'String',
validators: [],
setters: [],
getters: [],
options: { type: [Function: String] },
_index: null },
keyB:
{ path: 'keyB',
instance: 'ObjectID',
validators: [],
setters: [],
getters: [],
options: { type: [Function: ObjectId] },
_index: null },
_id:
{ path: '_id',
instance: 'ObjectID',
validators: [],
setters: [ [Function] ],
getters: [],
options: { type: [Function: ObjectId], auto: true },
_index: null,
defaultValue: [Function] } },
virtuals: { id: { getters: [ [Function] ], setters: [], options: {} } },
inherits: {},
callQueue: [],
_indexes: [],
methods: {},
statics: {},
tree:
{ keyA: [Function],
keyB: [Function],
_id: { auto: true, type: [Function] },
id: { getters: [ [Function] ], setters: [], options: {} } },
options: { strict: false, 'use$SetOnSave': true, safe: true } }
deepEqual
{ paths:
{ keyA:
{ enumValues: [],
regExp: null,
path: 'keyA',
instance: 'String',
validators: [],
setters: [],
getters: [],
options: { type: [Function: String] },
_index: null },
keyB:
{ path: 'keyB',
instance: 'ObjectID',
validators: [],
setters: [],
getters: [],
options: { type: [Function: ObjectId] },
_index: null },
_id:
{ path: '_id',
instance: 'ObjectID',
validators: [],
setters: [ [Function] ],
getters: [],
options: { type: [Function: ObjectId], auto: true },
_index: null,
defaultValue: [Function] } },
virtuals: { id: { getters: [ [Function] ], setters: [], options: {} } },
inherits: {},
callQueue: [],
_indexes: [],
methods: {},
statics: {},
tree:
{ keyA: [Function],
keyB: [Function],
_id: { auto: true, type: [Function] },
id: { getters: [ [Function] ], setters: [], options: {} } },
options: { strict: false, 'use$SetOnSave': true, safe: true } }
at Object.deepEqual (d:\Source\MySource\mongoose-strongly\tests\node_modules\nodeunit\lib\types.js:83:39)
A) I have to scan all the properties and try to see what's different, and B) the objects seem identical, what is actually different?
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
報告された deepEqual の失敗が発生する nodeunit/lib/types.js:83 から開始し、issue にある mongoose スキーマの例を再現します。比較された値がどのように表示されるかを追跡し、プロパティレベルの不一致についてどの情報が利用可能かを特定します。AssertionError が 2 つの完全なオブジェクトを出力するだけでなく、異なるプロパティまたは値を特定できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- testing-qa
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100