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.