We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi
Here's a very simple example
index.js
function foo() { } module.exports = { foo }
index.test.js
const rewire = require("rewire") const index = rewire("./index") const foo = index.foo console.log("typeof:", typeof foo) console.log("instanceof Function:", foo instanceof Function)
Run with Node
$ node index.test.js typeof: function instanceof Function: true
Run with Jest
$ jest index.test.js ... typeof: function instanceof Function: false ...
I'm really curious on why this happens, whether this is a bug, and how a function can be something else than an instance of Function.
The text was updated successfully, but these errors were encountered:
This is related to #164.
The reason is covered in this article by Manuel Spigolon:
I wrote a niche library called jewire to work around this issue:
Hope this helps :).
Sorry, something went wrong.
No branches or pull requests
Hi
Here's a very simple example
index.js
index.test.js
Run with Node
$ node index.test.js typeof: function instanceof Function: true
Run with Jest
$ jest index.test.js ... typeof: function instanceof Function: false ...
I'm really curious on why this happens, whether this is a bug, and how a function can be something else than an instance of Function.
The text was updated successfully, but these errors were encountered: