new EventEmitter() instanceof Object returns false when run by Jest
See original GitHub issueDo you want to request a feature or report a bug? bug
What is the current behavior?
On node an instance of EventEmitter are instances of Object
const { EventEmitter } = require('events');
const eventEmitter = new EventEmitter();
eventEmitter instanceof Object; //true
Running the same code inside a Jest run will report that this is false.
If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install
and yarn test
.
https://repl.it/@Aigeec/Jest-thinks-EventEmitter-is-not-an-object https://repl.it/@Aigeec/Node-thinks-EventEmitter-is-an-object
What is the expected behavior? In a Node env it should evaluate the same as Node.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system. Jest Config:
{
"testRegex": ".*-test\\.js$",
"testEnvironment": "node"
}
Using the repl versions: node v7.4 linux/amd64 Jest v20.0.4 node v7.4.0 linux/amd64
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Looks like a duplicate of #2549
I think it was a little ‘e’
typeof eventEmitter === 'object'
referring to the eventEmitter instance.In either case
EventEmitter instanceof Object
ornew EventEmitter() instanceof Object
will return false in a Jest environment but true in Node.