test.deepEqual may print incorrect property values for subsequently modified properties SERIOUS ISSUE
- Dominant language
- JavaScript
- Stars
- 1.9k
- Forks
- 359
- PR merge metrics
- No merged PRs in 30d
Description
test.deepEqual does not examine failing objects immediately, so incorrect values are printed
## Reproduction printout
```
$ nodeunit ../nodejs3/snippets/modules/nodeunit/nodeunit-changedobject.js
nodeunit-changedobject.js
Expected printout: AssertionError: { property: 'object1' } deepEqual { property: 'object2' }
✖ f
AssertionError: { property: 'overwite' } deepEqual { property: 'object2' }
at Object.assertWrapper [as deepEqual] (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at Object.module.exports.f (/home/foxyboy/Desktop/c505/node/nodejs3/snippets/modules/nodeunit/nodeunit-changedobject.js:13:7)
at Object.wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at Object.exports.runTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:69:9)
at exports.runSuite (/usr/local/lib/node_modules/nodeunit/lib/core.js:117:25)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:508:13)
at async.forEachSeries.iterate (/usr/local/lib/node_modules/nodeunit/deps/async.js:118:13)
at async.forEachSeries (/usr/local/lib/node_modules/nodeunit/deps/async.js:134:9)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:507:9)
```
## Reproduction code
``` js
// nodeunit-changedobject.js
module.exports.f = function (test) {
var object1 = {
property: 'object1'
}
var object2 = {
property: 'object2'
}
test.deepEqual(object1, object2)
object1.property = 'overwite'
console.log('Expected printout: AssertionError: { property: \'object1\' } deepEqual { property: \'object2\' }')
test.done()
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with test.deepEqual in lib/types.js, using the stack trace and the nodeunit-changedobject.js reproduction as the entry points. Run the supplied nodeunit example and compare the failure output with its expected printout; done means the reported values remain those present when deepEqual is called, rather than later mutations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100