UNPKG

stryker

Version:
58 lines 2.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var inquirer = require("inquirer"); var handbookUrl = 'https://github.com/stryker-mutator/stryker-handbook/blob/master/stryker/guides/react.md#react'; /** * More information can be found in the Stryker handbook: * https://github.com/stryker-mutator/stryker-handbook/blob/master/stryker/guides/react.md#react */ var ReactPreset = /** @class */ (function () { function ReactPreset() { this.name = 'react'; this.generalDependencies = [ 'stryker', 'stryker-jest-runner', 'stryker-html-reporter' ]; this.sharedConfig = "testRunner: 'jest',\n reporters: ['progress', 'clear-text', 'html'],\n coverageAnalysis: 'off',\n jest: {\n projectType: 'react'\n }\n "; this.tsxDependencies = ['stryker-typescript'].concat(this.generalDependencies); this.tsxConf = "{\n mutate: ['src/**/*.ts?(x)', '!src/**/*@(.test|.spec|Spec).ts?(x)'],\n mutator: 'typescript',\n " + this.sharedConfig + "\n }"; this.jsxDependencies = ['stryker-javascript-mutator'].concat(this.generalDependencies); this.jsxConf = "{\n mutate: ['src/**/*.js?(x)', '!src/**/*@(.test|.spec|Spec).js?(x)'],\n mutator: 'javascript',\n " + this.sharedConfig + "\n }"; } ReactPreset.prototype.createConfig = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { var choices, answers; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: choices = ['JSX', 'TSX']; return [4 /*yield*/, inquirer.prompt({ choices: choices, message: 'Is your project a JSX project or a TSX project?', name: 'choice', type: 'list' })]; case 1: answers = _a.sent(); return [2 /*return*/, this.load(answers.choice)]; } }); }); }; ReactPreset.prototype.load = function (choice) { if (choice === 'JSX') { return { config: this.jsxConf, handbookUrl: handbookUrl, dependencies: this.jsxDependencies }; } else if (choice === 'TSX') { return { config: this.tsxConf, handbookUrl: handbookUrl, dependencies: this.tsxDependencies }; } else { throw new Error("Invalid project type " + choice); } }; return ReactPreset; }()); exports.ReactPreset = ReactPreset; //# sourceMappingURL=ReactPreset.js.map