assert.{equal,strictEqual} do not print compared objects when comparing falsy values and message has been set
- 主要言語
- JavaScript
- スター
- 1.9k
- フォーク
- 359
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
This is the test module:
```
module.exports = {
'Falsy tests with messages': function(test) {
test.equal(1, undefined, "A message");
test.equal(1, null, "A message");
test.equal(1, false, "A message");
test.equal(1, 0, "A message");
test.equal(1, '', "A message");
test.done();
},
'Falsy tests without messages': function(test) {
test.equal(1, undefined);
test.equal(1, null);
test.equal(1, false);
test.equal(1, 0);
test.equal(1, '');
test.done();
}
};
```
And the output:
```
% nodeunit test.js |grep 'AssertionError\|Falsy'
✖ Falsy tests with messages
AssertionError: A message
AssertionError: A message
AssertionError: A message
AssertionError: A message
AssertionError: A message
✖ Falsy tests without messages
AssertionError: == 1
AssertionError: null == 1
AssertionError: false == 1
AssertionError: 0 == 1
AssertionError: "" == 1
```
The problem is in [utils.betterErrors, line 186](https://github.com/caolan/nodeunit/blob/master/lib/utils.js#L186). I think equal, strictEqual and friends should set a property indicating that they have indeed been passed expected and actual values instead of trying to guess.
BTW, undefined should probably print "undefined" or something like that. And it also is strange that, compared to equal, the expected and actual values order is reversed.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
lib/utils.js の betterErrors 付近、186 行目から始め、レポートに示されている JavaScript テストモジュールで問題を再現します。undefined を含む falsy 値について、メッセージありの場合となしの場合の失敗を比較します。完了条件は、アサーションの出力に比較対象の値が一貫して含まれ、expected/actual の順序が明確であることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, node.js
- 領域
- testing-qa
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100