caolan / caolan/nodeunit

assert.{equal,strictEqual} do not print compared objects when comparing falsy values and message has been set

Đang mở
#166 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
1.9k
Fork
359
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu tại lib/utils.js, quanh betterErrors, dòng 186, và tái hiện vấn đề bằng module kiểm thử JavaScript được nêu trong báo cáo. So sánh các lỗi khi có và không có thông báo đối với các giá trị falsy, bao gồm undefined. Hoàn tất nghĩa là đầu ra của assertion luôn bao gồm các giá trị được so sánh và có thứ tự expected/actual rõ ràng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
testing-qa
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.