question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The actual result is different from expected, but test still pass.

See original GitHub issue

Challenge 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"]

actual <=> expected 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:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Manish-Giricommented, Nov 6, 2016

@erictleung I’ll work on this. I will PM you the change I made before submitting a PR, so you can approve the wording.

0reactions
erictleungcommented, Nov 7, 2016

@Manish-Giri go for it! The “Note” part should be in <strong> tags by the way.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found