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
I've adapted the "proxyquire" scenario from the tests to show an issue. Below, I've added a second assertion, and a third file, c.js. The assertions made below, using CJS, pass (to prove it works as intended):
// index.jsconstassert=require("assert")constproxyquire=require("proxyquire")// `path` and `b.js` are stubbed ONLY in a.jsconsta=proxyquire.load("./a.js",{path: {extname: ()=>"c"},"./b.js": "b"})assert.strictEqual(a(),"abc")// `path` and `b.js` are now stubbed when loaded by ANY moduleconstb=newString("b")// this is hideous, but what can you do?b["@global"]=trueconstc=proxyquire.load("./c.js",{path: {extname: ()=>"c","@global": true},"./b.js": b})assert.strictEqual(c(),"abc")
AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
+ expected - actual
- 'ab'
+ 'abc'
at Object.<anonymous> (/Users/boneskull/projects/standard-things/esm/test/fixture/scenario/proxyquire/index.js:25:8)
at Generator.next (<anonymous>)
If we remove that unused import in c.js:
// c.jsimportafrom"./a.js"exportdefault()=>a()
the assertion passes.
I don't know what the problem is, but that's why I'm making this issue.
I can replicate this behavior in bothrewiremock and proxyquire. I'll probably send a PR to add some rewiremock tests.
The text was updated successfully, but these errors were encountered:
I've adapted the "proxyquire" scenario from the tests to show an issue. Below, I've added a second assertion, and a third file,
c.js
. The assertions made below, using CJS, pass (to prove it works as intended):Now, if we write these using ES modules via
node -r esm
:The result:
If we remove that unused import in
c.js
:the assertion passes.
I don't know what the problem is, but that's why I'm making this issue.
I can replicate this behavior in both rewiremock and proxyquire. I'll probably send a PR to add some rewiremock tests.
The text was updated successfully, but these errors were encountered: