UNPKG

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