Skip to content

Commit 9ea1a64

Browse files
committedMay 6, 2023
fix: add SUPPRESS_JEST_WARNINGS environment variable to silence jest warnings
Fix #13373
1 parent 76e6456 commit 9ea1a64

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed
 

‎lib/helpers/printJestWarning.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
const utils = require('../utils');
44

5-
if (typeof jest !== 'undefined' && typeof window !== 'undefined') {
6-
utils.warn('Mongoose: looks like you\'re trying to test a Mongoose app ' +
7-
'with Jest\'s default jsdom test environment. Please make sure you read ' +
8-
'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
9-
'https://mongoosejs.com/docs/jest.html');
10-
}
5+
if (typeof jest !== 'undefined' && !process.env.SUPPRESS_JEST_WARNINGS) {
6+
if (typeof window !== 'undefined') {
7+
utils.warn('Mongoose: looks like you\'re trying to test a Mongoose app ' +
8+
'with Jest\'s default jsdom test environment. Please make sure you read ' +
9+
'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
10+
'https://mongoosejs.com/docs/jest.html');
11+
}
1112

12-
if (typeof jest !== 'undefined' && setTimeout.clock != null && typeof setTimeout.clock.Date === 'function') {
13-
utils.warn('Mongoose: looks like you\'re trying to test a Mongoose app ' +
14-
'with Jest\'s mock timers enabled. Please make sure you read ' +
15-
'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
16-
'https://mongoosejs.com/docs/jest.html');
13+
if (setTimeout.clock != null && typeof setTimeout.clock.Date === 'function') {
14+
utils.warn('Mongoose: looks like you\'re trying to test a Mongoose app ' +
15+
'with Jest\'s mock timers enabled. Please make sure you read ' +
16+
'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
17+
'https://mongoosejs.com/docs/jest.html');
18+
}
1719
}

0 commit comments

Comments
 (0)
Please sign in to comment.