presets.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var JestPresetNames;
  4. (function (JestPresetNames) {
  5. JestPresetNames["default"] = "ts-jest/presets/default";
  6. JestPresetNames["jsWithTs"] = "ts-jest/presets/js-with-ts";
  7. JestPresetNames["jsWIthBabel"] = "ts-jest/presets/js-with-babel";
  8. })(JestPresetNames = exports.JestPresetNames || (exports.JestPresetNames = {}));
  9. var definePreset = function (fullName) { return ({
  10. fullName: fullName,
  11. get name() {
  12. return this.isDefault ? 'ts-jest' : fullName;
  13. },
  14. get label() {
  15. return fullName.split('/').pop();
  16. },
  17. get jsVarName() {
  18. return this.isDefault
  19. ? 'defaults'
  20. : fullName
  21. .split('/')
  22. .pop()
  23. .replace(/\-([a-z])/g, function (_, l) { return l.toUpperCase(); });
  24. },
  25. get value() {
  26. return require("../../../" + fullName.replace(/^ts-jest\//, '') + "/jest-preset");
  27. },
  28. jsImport: function (varName) {
  29. if (varName === void 0) { varName = 'tsjPreset'; }
  30. return "const { " + this.jsVarName + ": " + varName + " } = require('ts-jest/presets')";
  31. },
  32. get isDefault() {
  33. return fullName === JestPresetNames.default;
  34. },
  35. }); };
  36. exports.allPresets = {};
  37. exports.defaults = (exports.allPresets[JestPresetNames.default] = definePreset(JestPresetNames.default));
  38. exports.jsWithTs = (exports.allPresets[JestPresetNames.jsWithTs] = definePreset(JestPresetNames.jsWithTs));
  39. exports.jsWIthBabel = (exports.allPresets[JestPresetNames.jsWIthBabel] = definePreset(JestPresetNames.jsWIthBabel));