You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Someone send a PR to node-tap that defends against tests that might mutate Object.prototype, essentially replacing some for (var i in obj) loops with Object.keys(obj).forEach(..), or adding a if(obj.hasOwnProperty(i)) guard.
Here's the test:
// test/has-own-property.jsObject.prototype.foo='bar'require('../').pass('modifying Object.prototype did not break things')
Running with coverage does this:
$ nyc node test/has-own-property.js
Transformation error for /Users/isaacs/dev/js/tap/lib/root.js ; return original code
Cannot assign to read only property 'optional' of bar
Transformation error for /Users/isaacs/dev/js/tap/lib/test.js ; return original code
Cannot assign to read only property 'optional' of bar
Transformation error for /Users/isaacs/dev/js/tap/lib/stack.js ; return original code
Cannot assign to read only property 'optional' of bar
Transformation error for /Users/isaacs/dev/js/tap/lib/assert.js ; return original code
Cannot assign to read only property 'optional' of bar
Transformation error for /Users/isaacs/dev/js/tap/lib/synonyms.js ; return original code
Cannot assign to read only property 'optional' of bar
Transformation error for /Users/isaacs/dev/js/tap/lib/mocha.js ; return original code
Cannot assign to read only property 'optional' of bar
TAP version 13
ok 1 - modifying Object.prototype did not break things
1..1
# time=23.336ms
----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files | Unknown | Unknown | Unknown | Unknown | |
----------|----------|----------|----------|----------|----------------|
I was able to make a simpler example but it has a different error:
The same things are still tested, but this test file makes `npm test`
spew tons of errors. Revert this commit when istanbul is resilient
against Object.prototype mutations.
See istanbuljs-archived-repos/istanbul-lib-instrument#18
Someone send a PR to node-tap that defends against tests that might mutate
Object.prototype
, essentially replacing somefor (var i in obj)
loops withObject.keys(obj).forEach(..)
, or adding aif(obj.hasOwnProperty(i))
guard.Here's the test:
Running with coverage does this:
I was able to make a simpler example but it has a different error:
The text was updated successfully, but these errors were encountered: