standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

add tests to assert rewiremock compatibility #799

Open boneskull opened 5 years ago

boneskull commented 5 years ago

rewiremock: https://npm.im/rewiremock

theKashey commented 5 years ago

The only incompatibility with esm I am aware of, was bound to callThought and default export, as long as esm expects __esModules to be a property, not only a value, while other systems (babel/webpack) are not checking details.

It would be better rewrite one test to:

const c = rewiremock.proxy("./c.js", () => {
  rewiremock(() => require('path')).with({
    extname: () => "b"
  });
  rewiremock(() => require('./b.js')).with("c");
});

As long as it's much more complex "inside", mocking Module._load twice - first to resolve name, and then to actually mock. 🙏

jdalton commented 5 years ago

Are the tests supposed to pass? Or fail and show an issue I need to resolve?

theKashey commented 5 years ago

Unfortunately the are passing.