Reputation: 21757
Testing with Jest endpoint of ExpressJS with Mongoose middleware I came across with the following error:
Mongoose: looks like you're trying to test a Mongoose app with Jest's default jsdom test environment. Please make sure you read Mongoose's docs on configuring Jest to test Node.js apps: http://mongoosejs.com/docs/jest.html
What is the issue?
Upvotes: 2
Views: 4204
Reputation: 231
"scripts": {
"test": "jest --testEnvironment=node --verbose --forceExit --watchAll --maxWorkers=1"
}
Issue Resolved!
Upvotes: 13
Reputation: 21757
According to official documentation for Mongoose you need to solve this problem by creating jest.config.js
with the following content:
module.exports = {
testEnvironment: 'node'
};
And guess what? It has solved my issue pretty painlessly :-)
Upvotes: 8