The actual result is different from expected, but test still pass.
See original GitHub issueChallenge Diff Two Arrays has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
The actual result is different from expected, but test still pass.
Actual : expected
["pink wool", "diorite"] : ["diorite", "pink wool"]
My code:
function diffArray(arr1, arr2) {
var newArr = [];
var set = new Set([...arr1, ...arr2]);
set.forEach(function (item) {
if (arr1.indexOf(item) === -1 || arr2.indexOf(item) === -1) {
newArr.push(item);
}
});
return newArr;
}
diffArray(["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
c# - Why my expected and actual results are same but test fails?
The reason for this is that objects are not compared by the values of their properties but by their reference.
Read more >Stop requiring only one assertion per unit test
It's a statement that we expect a particular outcome. We then compare the actual outcome to the expected outcome to see if they...
Read more >Snapshot Testing - Jest
If they match, the test will pass. If they don't match, either the test runner found a bug in your code (in the...
Read more >Unit testing fundamentals - Visual Studio (Windows)
Learn how Visual Studio Test Explorer provides a flexible and efficient way to run your unit tests and view their results.
Read more >Effective Python Testing With Pytest
xfail indicates that a test is expected to fail, so if the test does fail, the overall suite can still result in a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@erictleung I’ll work on this. I will PM you the change I made before submitting a PR, so you can approve the wording.
@Manish-Giri go for it! The “Note” part should be in
<strong>
tags by the way.