Object literals: Compared values have no visual difference.
See original GitHub issueSystem:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
Binaries:
npm: 5.8.0 - C:\Users\Owner\AppData\Roaming\npm\npm.CMD
I am on jest@22.4.3
.
The two objects are the same. I’ve done some research, and it seems that the Compared values have no visual difference.
occurs when there is an anonymous function in question. This is not the case.
Here’s the code:
const stripData = obj => obj.data
const assign = child => parent => Object.assign(parent, child)
const arrAssign = (arr, k) => data => data.map((d, i) => assign({[k]: d})(arr[i]))
/* function being tested */
const insertAndPair = (obj, key1, key2) => compose(
d => assign({ [key1]: arrAssign(obj.slice(-1)[0][key1], key2)(d) })(obj.slice(-1)),
stripData
)
Here’s the test:
it('given an array and key then an object, assigns the first'
+ ' element in the array to the object with the given key', () => {
const arr = [{
vals: [
{ x: [], y: 'hello'},
{ x: [], y: 'hey'}
]
}]
expect(
insertAndPair(arr, 'vals', 'x')({data: [1, 2]})
).toEqual([ { vals: [
{ x: 1, y: 'hello' },
{ x: 2, y: 'hey' }
] } ])
})
Pardon my convoluted code, haha!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Jest Test "Compared values have no visual difference."
The test fails with the error Compared values have no visual difference . To understand what is going on I recommend to log...
Read more >Jest Test "Compared values have no visual difference."-Reactjs
The test fails with the error Compared values have no visual difference . To understand what is going on I recommend to log...
Read more >Expect - Jest
The expect function is used every time you want to test a value. ... It calls Object.is to compare values, which is even...
Read more >JavaScript Objects - W3Schools
All JavaScript values, except primitives, are objects. JavaScript Primitives. A primitive value is a value that has no properties or methods.
Read more >Python '!=' Is Not 'is not': Comparing Objects in Python
When to use equality and identity operators to compare objects; What these Python operators do under the hood; Why using is and is...
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 FreeTop 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
Top GitHub Comments
Wrapping them both in
JSON.stringify
passes the test, but I find this to be a workaround rather than a fix.@SimenB how about “Compared values have no visual difference but may have different properties.”