1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _jestConfig() {
|
9 | const data = require('jest-config');
|
10 |
|
11 | _jestConfig = function _jestConfig() {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | const stringifyOption = (option, map, linePrefix = '') => {
|
25 | const optionDescription = ` // ${_jestConfig().descriptions[option]}`;
|
26 | const stringifiedObject = `${option}: ${JSON.stringify(
|
27 | map[option],
|
28 | null,
|
29 | 2
|
30 | )}`;
|
31 | return (
|
32 | optionDescription +
|
33 | '\n' +
|
34 | stringifiedObject
|
35 | .split('\n')
|
36 | .map(line => ' ' + linePrefix + line)
|
37 | .join('\n') +
|
38 | ',\n'
|
39 | );
|
40 | };
|
41 |
|
42 | const generateConfigFile = results => {
|
43 | const coverage = results.coverage,
|
44 | clearMocks = results.clearMocks,
|
45 | environment = results.environment;
|
46 | const overrides = {};
|
47 |
|
48 | if (coverage) {
|
49 | Object.assign(overrides, {
|
50 | coverageDirectory: 'coverage'
|
51 | });
|
52 | }
|
53 |
|
54 | if (environment === 'node') {
|
55 | Object.assign(overrides, {
|
56 | testEnvironment: 'node'
|
57 | });
|
58 | }
|
59 |
|
60 | if (clearMocks) {
|
61 | Object.assign(overrides, {
|
62 | clearMocks: true
|
63 | });
|
64 | }
|
65 |
|
66 | const overrideKeys = Object.keys(overrides);
|
67 | const properties = [];
|
68 |
|
69 | for (const option in _jestConfig().descriptions) {
|
70 | const opt = option;
|
71 |
|
72 | if (overrideKeys.includes(opt)) {
|
73 | properties.push(stringifyOption(opt, overrides));
|
74 | } else {
|
75 | properties.push(stringifyOption(opt, _jestConfig().defaults, '// '));
|
76 | }
|
77 | }
|
78 |
|
79 | return (
|
80 | '// For a detailed explanation regarding each configuration property, visit:\n' +
|
81 | '// https://jestjs.io/docs/en/configuration.html\n\n' +
|
82 | 'module.exports = {\n' +
|
83 | properties.join('\n') +
|
84 | '};\n'
|
85 | );
|
86 | };
|
87 |
|
88 | var _default = generateConfigFile;
|
89 | exports.default = _default;
|