stryker
Version:
The extendable JavaScript mutation testing framework
149 lines • 7.43 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var inquirer = require("inquirer");
var CommandTestRunner_1 = require("../test-runner/CommandTestRunner");
var StrykerInquirer = /** @class */ (function () {
function StrykerInquirer() {
}
StrykerInquirer.prototype.promptPresets = function (options) {
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 = options.map(function (_) { return _.name; });
choices.push(new inquirer.Separator());
choices.push('None/other');
return [4 /*yield*/, inquirer.prompt({
choices: choices,
message: 'Are you using one of these frameworks? Then select a preset configuration.',
name: 'preset',
type: 'list'
})];
case 1:
answers = _a.sent();
return [2 /*return*/, options.find(function (_) { return _.name === answers.preset; })];
}
});
});
};
StrykerInquirer.prototype.promptTestRunners = function (options) {
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 = options.map(function (_) { return _.name; });
choices.push(new inquirer.Separator());
choices.push(CommandTestRunner_1.default.runnerName);
return [4 /*yield*/, inquirer.prompt({
choices: choices,
default: 'Mocha',
message: 'Which test runner do you want to use? If your test runner isn\'t listed here, you can choose "command" (it uses your `npm test` command, but will come with a big performance penalty)',
name: 'testRunner',
type: 'list'
})];
case 1:
answers = _a.sent();
return [2 /*return*/, options.filter(function (_) { return _.name === answers.testRunner; })[0] || { name: CommandTestRunner_1.default.runnerName }];
}
});
});
};
StrykerInquirer.prototype.promptTestFrameworks = function (options) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var answers;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, inquirer.prompt({
choices: options.map(function (_) { return _.name; }),
message: 'Which test framework do you want to use?',
name: 'testFramework',
type: 'list'
})];
case 1:
answers = _a.sent();
return [2 /*return*/, options.filter(function (_) { return _.name === answers.testFramework; })[0]];
}
});
});
};
StrykerInquirer.prototype.promptMutator = function (options) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var answers;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, inquirer.prompt({
choices: options.map(function (_) { return _.name; }),
message: 'What kind of code do you want to mutate?',
name: 'mutator',
type: 'list'
})];
case 1:
answers = _a.sent();
return [2 /*return*/, options.filter(function (_) { return _.name === answers.mutator; })[0]];
}
});
});
};
StrykerInquirer.prototype.promptTranspilers = function (options) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var answers;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, inquirer.prompt({
choices: options.map(function (_) { return _.name; }),
message: '[optional] What kind transformations should be applied to your code?',
name: 'transpilers',
type: 'checkbox'
})];
case 1:
answers = _a.sent();
return [2 /*return*/, options.filter(function (option) { return answers.transpilers.some(function (transpilerName) { return option.name === transpilerName; }); })];
}
});
});
};
StrykerInquirer.prototype.promptReporters = function (options) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var answers;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, inquirer.prompt({
choices: options.map(function (_) { return _.name; }),
default: ['clear-text', 'progress'],
message: 'Which reporter(s) do you want to use?',
name: 'reporters',
type: 'checkbox'
})];
case 1:
answers = _a.sent();
return [2 /*return*/, options.filter(function (option) { return answers.reporters.some(function (reporterName) { return option.name === reporterName; }); })];
}
});
});
};
StrykerInquirer.prototype.promptPackageManager = function (options) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var answers;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, inquirer.prompt({
choices: options.map(function (_) { return _.name; }),
default: ['npm'],
message: 'Which package manager do you want to use?',
name: 'packageManager',
type: 'list'
})];
case 1:
answers = _a.sent();
return [2 /*return*/, options.filter(function (_) { return _.name === answers.packageManager; })[0]];
}
});
});
};
return StrykerInquirer;
}());
exports.StrykerInquirer = StrykerInquirer;
//# sourceMappingURL=StrykerInquirer.js.map
;