euank/node-noop

"should not mutate global" test not valid

Closed this issue · 1 comments

The "should not mutate global" is not working as intended:

  it('should not mutate global', function() {
    var globalBefore = global;
    noop.noop();
    assert.equal(globalBefore, global);
  });

var globalBefore = global; only copies the reference to the global object, it does not create a copy. When assert.equals compares global with globalBefore the reference is still the same, even if global has been mutated in the meantime. So this test is always successful.

I'd post a PR to fix this, but I'm not sure what would be the best way to actually identify mutations. You could clone (e.g. using Lodash) the global object, but that isn't very elegant and I'm not even sure if it would work.

just noticed there's already a pull request for this :)