-
Notifications
You must be signed in to change notification settings - Fork 83
/
helpers.js
44 lines (36 loc) · 1002 Bytes
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const {resolve} = require('path');
const cwd = process.cwd();
const configFile = process.env.MONGO_MEMORY_SERVER_FILE || 'jest-mongodb-config.js';
module.exports.getMongodbMemoryOptions = function () {
try {
const {mongodbMemoryServerOptions} = require(resolve(cwd, configFile));
return mongodbMemoryServerOptions;
} catch (e) {
return {
binary: {
skipMD5: true,
},
autoStart: false,
instance: {},
};
}
};
module.exports.getMongoURLEnvName = function () {
try {
const {mongoURLEnvName} = require(resolve(cwd, configFile));
return mongoURLEnvName || 'MONGO_URL';
} catch (e) {
return 'MONGO_URL';
}
};
module.exports.shouldUseSharedDBForAllJestWorkers = function () {
try {
const {useSharedDBForAllJestWorkers} = require(resolve(cwd, configFile));
if (typeof useSharedDBForAllJestWorkers === 'undefined') {
return true;
}
return useSharedDBForAllJestWorkers;
} catch (e) {
return true;
}
};