updateGlobalConfig.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _jestRegexUtil() {
  7. const data = require('jest-regex-util');
  8. _jestRegexUtil = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. /**
  14. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  15. *
  16. * This source code is licensed under the MIT license found in the
  17. * LICENSE file in the root directory of this source tree.
  18. */
  19. var _default = (globalConfig, options = {}) => {
  20. const newConfig = {...globalConfig};
  21. if (options.mode === 'watch') {
  22. newConfig.watch = true;
  23. newConfig.watchAll = false;
  24. } else if (options.mode === 'watchAll') {
  25. newConfig.watch = false;
  26. newConfig.watchAll = true;
  27. }
  28. if (options.testNamePattern !== undefined) {
  29. newConfig.testNamePattern = options.testNamePattern || '';
  30. }
  31. if (options.testPathPattern !== undefined) {
  32. newConfig.testPathPattern =
  33. (0, _jestRegexUtil().replacePathSepForRegex)(options.testPathPattern) ||
  34. '';
  35. }
  36. newConfig.onlyChanged = false;
  37. newConfig.onlyChanged =
  38. !newConfig.watchAll &&
  39. !newConfig.testNamePattern &&
  40. !newConfig.testPathPattern;
  41. if (typeof options.bail === 'boolean') {
  42. newConfig.bail = options.bail ? 1 : 0;
  43. } else if (options.bail !== undefined) {
  44. newConfig.bail = options.bail;
  45. }
  46. if (options.changedSince !== undefined) {
  47. newConfig.changedSince = options.changedSince;
  48. }
  49. if (options.collectCoverage !== undefined) {
  50. newConfig.collectCoverage = options.collectCoverage || false;
  51. }
  52. if (options.collectCoverageFrom !== undefined) {
  53. newConfig.collectCoverageFrom = options.collectCoverageFrom;
  54. }
  55. if (options.collectCoverageOnlyFrom !== undefined) {
  56. newConfig.collectCoverageOnlyFrom = options.collectCoverageOnlyFrom;
  57. }
  58. if (options.coverageDirectory !== undefined) {
  59. newConfig.coverageDirectory = options.coverageDirectory;
  60. }
  61. if (options.coverageReporters !== undefined) {
  62. newConfig.coverageReporters = options.coverageReporters;
  63. }
  64. if (options.findRelatedTests !== undefined) {
  65. newConfig.findRelatedTests = options.findRelatedTests;
  66. }
  67. if (options.nonFlagArgs !== undefined) {
  68. newConfig.nonFlagArgs = options.nonFlagArgs;
  69. }
  70. if (options.noSCM) {
  71. newConfig.noSCM = true;
  72. }
  73. if (options.notify !== undefined) {
  74. newConfig.notify = options.notify || false;
  75. }
  76. if (options.notifyMode !== undefined) {
  77. newConfig.notifyMode = options.notifyMode;
  78. }
  79. if (options.onlyFailures !== undefined) {
  80. newConfig.onlyFailures = options.onlyFailures || false;
  81. }
  82. if (options.passWithNoTests !== undefined) {
  83. newConfig.passWithNoTests = true;
  84. }
  85. if (options.reporters !== undefined) {
  86. newConfig.reporters = options.reporters;
  87. }
  88. if (options.updateSnapshot !== undefined) {
  89. newConfig.updateSnapshot = options.updateSnapshot;
  90. }
  91. if (options.verbose !== undefined) {
  92. newConfig.verbose = options.verbose || false;
  93. }
  94. return Object.freeze(newConfig);
  95. };
  96. exports.default = _default;