A coworker was asking me about noPreserveCache and when it is/isn't needed, and I was a bit surprised to find the example in the docs for preserveCache are no longer accurate. In short, it seems like the answer is now 'noPreserveCache' is never explicitly needed, because it's the default :)
Based on https://github.com/thlorenz/proxyquire#forcing-proxyquire-to-reload-modules:
var proxyquire = require('proxyquire').preserveCache();
var assert = require('assert');
var stubs = {};
var foo1 = proxyquire('./foo', stubs);
var foo2 = proxyquire('./foo', stubs);
var foo3 = require('./foo');
assert.equal(foo1, foo2);
assert.equal(foo1, foo3);
For testing, I created a simple foo.js with a single line module.exports = {};
The asserts fail with an error like:
AssertionError [ERR_ASSERTION]: {} == {}
Is this expected? I haven't found any recently issues/PRs (yet) that justify this change in behavior.
This was using proxyquire v2.1.0
A coworker was asking me about
noPreserveCacheand when it is/isn't needed, and I was a bit surprised to find the example in the docs forpreserveCacheare no longer accurate. In short, it seems like the answer is now 'noPreserveCache' is never explicitly needed, because it's the default :)Based on https://github.com/thlorenz/proxyquire#forcing-proxyquire-to-reload-modules:
For testing, I created a simple
foo.jswith a single linemodule.exports = {};The asserts fail with an error like:
Is this expected? I haven't found any recently issues/PRs (yet) that justify this change in behavior.
This was using proxyquire v2.1.0