New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stryker

Package Overview
Dependencies
Maintainers
2
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stryker - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

src/initializer/NpmClient.d.ts

12

package.json
{
"name": "stryker",
"version": "0.6.1",
"version": "0.6.2",
"description": "The extendable JavaScript mutation testing framework",

@@ -60,2 +60,3 @@ "main": "src/Stryker.js",

"glob": "^7.0.3",
"inquirer": "^3.0.6",
"istanbul": "^0.4.5",

@@ -69,10 +70,13 @@ "lodash": "^4.17.4",

"serialize-javascript": "^1.3.0",
"tslib": "^1.5.0"
"tslib": "^1.5.0",
"typed-rest-client": "^0.10.0"
},
"devDependencies": {
"stryker-api": "^0.5.0"
"@types/commander": "^2.9.0",
"@types/inquirer": "0.0.33",
"stryker-api": "^0.5.1"
},
"peerDependencies": {
"stryker-api": "^0.5.0"
"stryker-api": "^0.5.1"
}
}
import IsolatedTestRunnerAdapter from './IsolatedTestRunnerAdapter';
import IsolatedRunnerOptions from './IsolatedRunnerOptions';
declare var _default: {
declare const _default: {
create(settings: IsolatedRunnerOptions): IsolatedTestRunnerAdapter;
};
export default _default;
import IsolatedRunnerOptions from './IsolatedRunnerOptions';
import TestRunnerDecorator from './TestRunnerDecorator';
declare var _default: {
declare const _default: {
create(testRunnerName: string, settings: IsolatedRunnerOptions): TestRunnerDecorator;
};
export default _default;

@@ -1,2 +0,2 @@

import { Reporter, SourceFile, MutantResult, MatchedMutant } from 'stryker-api/report';
import { Reporter, SourceFile, MutantResult, MatchedMutant, ScoreResult } from 'stryker-api/report';
import StrictReporter from './StrictReporter';

@@ -16,4 +16,5 @@ export interface NamedReporter {

onAllMutantsTested(results: MutantResult[]): void;
onScoreCalculated(score: ScoreResult): void;
wrapUp(): void | Promise<void>;
private handleError(error, methodName, reporterName);
}

@@ -48,2 +48,5 @@ "use strict";

};
BroadcastReporter.prototype.onScoreCalculated = function (score) {
this.broadcast('onScoreCalculated', score);
};
BroadcastReporter.prototype.wrapUp = function () {

@@ -50,0 +53,0 @@ return this.broadcast('wrapUp');

@@ -1,2 +0,2 @@

import { Reporter, MutantResult } from 'stryker-api/report';
import { Reporter, MutantResult, ScoreResult } from 'stryker-api/report';
import { StrykerOptions } from 'stryker-api/core';

@@ -11,9 +11,3 @@ export default class ClearTextReporter implements Reporter {

private logExecutedTests(result, logImplementation);
/**
* Gets the color associated with a mutation score.
* @function
* @param score - The mutation score.
* @returns {Function} The function which can give the mutation score the right color.
*/
private getColorForMutationScore(score);
onScoreCalculated(score: ScoreResult): void;
}

@@ -6,2 +6,4 @@ "use strict";

var report_1 = require("stryker-api/report");
var ClearTextScoreTable_1 = require("./ClearTextScoreTable");
var os = require("os");
var log = log4js.getLogger('ClearTextReporter');

@@ -14,3 +16,3 @@ var ClearTextReporter = (function () {

ClearTextReporter.prototype.writeLine = function (output) {
this.out.write((output || '') + "\n");
this.out.write("" + (output || '') + os.EOL);
};

@@ -21,7 +23,2 @@ ClearTextReporter.prototype.onAllMutantsTested = function (mutantResults) {

var totalTests = 0;
var mutantsKilled = 0;
var mutantsTimedOut = 0;
var mutantsNoCoverage = 0;
var mutantsSurvived = 0;
var mutantsErrored = 0;
// use these fn's in order to preserve the 'this` pointer

@@ -36,3 +33,2 @@ var logDebugFn = function (input) { return log.debug(input); };

case report_1.MutantStatus.Killed:
mutantsKilled++;
log.debug(chalk.bold.green('Mutant killed!'));

@@ -42,3 +38,2 @@ _this.logMutantResult(result, logDebugFn);

case report_1.MutantStatus.TimedOut:
mutantsTimedOut++;
log.debug(chalk.bold.yellow('Mutant timed out!'));

@@ -48,3 +43,2 @@ _this.logMutantResult(result, logDebugFn);

case report_1.MutantStatus.Error:
mutantsErrored++;
log.debug(chalk.bold.yellow('Mutant caused an error!'));

@@ -54,3 +48,2 @@ _this.logMutantResult(result, logDebugFn);

case report_1.MutantStatus.Survived:
mutantsSurvived++;
_this.writeLine(chalk.bold.red('Mutant survived!'));

@@ -60,3 +53,2 @@ _this.logMutantResult(result, writeLineFn);

case report_1.MutantStatus.NoCoverage:
mutantsNoCoverage++;
_this.writeLine(chalk.bold.yellow('Mutant survived! (no coverage)'));

@@ -67,25 +59,3 @@ _this.logMutantResult(result, writeLineFn);

});
var mutantsWithoutErrors = mutantResults.length - mutantsErrored;
var mutationScoreCodebase = (((mutantsKilled + mutantsTimedOut) / mutantsWithoutErrors) * 100).toFixed(2);
var mutationScoreCodeCoverage = (((mutantsKilled + mutantsTimedOut) / ((mutantsWithoutErrors - mutantsNoCoverage) || 1)) * 100).toFixed(2);
var codebaseColor = this.getColorForMutationScore(+mutationScoreCodebase);
var codecoverageColor = this.getColorForMutationScore(+mutationScoreCodeCoverage);
this.writeLine(mutantResults.length + " total mutants.");
this.writeLine((mutantsSurvived + mutantsNoCoverage) + ' mutants survived.');
if (mutantsNoCoverage > 0) {
this.writeLine(" of which " + mutantsNoCoverage + " were not covered by the tests.");
}
if (mutantsErrored > 0) {
this.writeLine(mutantsErrored + ' mutant(s) caused an error and were therefore not accounted for in the mutation score.');
}
this.writeLine(mutantsTimedOut + ' mutants timed out.');
this.writeLine(mutantsKilled + ' mutants killed.');
this.writeLine("Ran " + (totalTests / mutantResults.length).toFixed(2) + " tests per mutant on average.");
if (this.options.coverageAnalysis === 'off') {
this.writeLine("Mutation score based on covered code: n/a");
}
else {
this.writeLine("Mutation score based on covered code: " + codecoverageColor(mutationScoreCodeCoverage + '%'));
}
this.writeLine("Mutation score based on all code: " + codebaseColor(mutationScoreCodebase + '%'));
};

@@ -131,20 +101,4 @@ ClearTextReporter.prototype.logMutantResult = function (result, logImplementation) {

};
/**
* Gets the color associated with a mutation score.
* @function
* @param score - The mutation score.
* @returns {Function} The function which can give the mutation score the right color.
*/
ClearTextReporter.prototype.getColorForMutationScore = function (score) {
var color;
if (score > 80) {
color = chalk.green;
}
else if (score > 50) {
color = chalk.yellow;
}
else {
color = chalk.red;
}
return color;
ClearTextReporter.prototype.onScoreCalculated = function (score) {
this.writeLine(new ClearTextScoreTable_1.default(score).draw());
};

@@ -151,0 +105,0 @@ return ClearTextReporter;

import { StrykerOptions } from 'stryker-api/core';
import { SourceFile, MutantResult, MatchedMutant } from 'stryker-api/report';
import { SourceFile, MutantResult, MatchedMutant, Reporter, ScoreResult } from 'stryker-api/report';
import StrictReporter from './StrictReporter';

@@ -12,4 +12,5 @@ export default class EventRecorderReporter implements StrictReporter {

private readonly baseFolder;
private writeToFile(index, methodName, data);
private writeToFile(methodName, data);
private format(input);
work(eventName: keyof Reporter, data: any): void;
onSourceFileRead(file: SourceFile): void;

@@ -19,4 +20,5 @@ onAllSourceFilesRead(files: SourceFile[]): void;

onMutantTested(result: MutantResult): void;
onScoreCalculated(score: ScoreResult): void;
onAllMutantsTested(results: MutantResult[]): void;
wrapUp(): Promise<any>;
}

@@ -34,4 +34,4 @@ "use strict";

});
EventRecorderReporter.prototype.writeToFile = function (index, methodName, data) {
var filename = path.join(this.baseFolder, this.format(index) + "-" + methodName + ".json");
EventRecorderReporter.prototype.writeToFile = function (methodName, data) {
var filename = path.join(this.baseFolder, this.format(this.index++) + "-" + methodName + ".json");
log.debug("Writing event " + methodName + " to file " + filename);

@@ -49,22 +49,23 @@ return fs.writeFile(filename, JSON.stringify(data), { encoding: 'utf8' });

};
EventRecorderReporter.prototype.onSourceFileRead = function (file) {
EventRecorderReporter.prototype.work = function (eventName, data) {
var _this = this;
this.allWork.push(this.createBaseFolderTask
.then(function () { return _this.writeToFile(_this.index++, 'onSourceFileRead', file); }));
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(eventName, data); }));
};
EventRecorderReporter.prototype.onSourceFileRead = function (file) {
this.work('onSourceFileRead', file);
};
EventRecorderReporter.prototype.onAllSourceFilesRead = function (files) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onAllSourceFilesRead', files); }));
this.work('onAllSourceFilesRead', files);
};
EventRecorderReporter.prototype.onAllMutantsMatchedWithTests = function (results) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onAllMutantsMatchedWithTests', results); }));
this.work('onAllMutantsMatchedWithTests', results);
};
EventRecorderReporter.prototype.onMutantTested = function (result) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onMutantTested', result); }));
this.work('onMutantTested', result);
};
EventRecorderReporter.prototype.onScoreCalculated = function (score) {
this.work('onScoreCalculated', score);
};
EventRecorderReporter.prototype.onAllMutantsTested = function (results) {
var _this = this;
this.allWork.push(this.createBaseFolderTask.then(function () { return _this.writeToFile(_this.index++, 'onAllMutantsTested', results); }));
this.work('onAllMutantsTested', results);
};

@@ -71,0 +72,0 @@ EventRecorderReporter.prototype.wrapUp = function () {

@@ -1,2 +0,2 @@

import { Reporter, SourceFile, MutantResult, MatchedMutant } from 'stryker-api/report';
import { Reporter, SourceFile, MutantResult, MatchedMutant, ScoreResult } from 'stryker-api/report';
/**

@@ -11,4 +11,5 @@ * Represents a Stryker reporter with all methods implemented

onAllMutantsTested(results: MutantResult[]): void;
onScoreCalculated(score: ScoreResult): void;
wrapUp(): void | Promise<void>;
}
export default StrictReporter;

@@ -6,2 +6,3 @@ "use strict";

var Stryker_1 = require("./Stryker");
var StrykerInitializer_1 = require("./initializer/StrykerInitializer");
var log4js = require("log4js");

@@ -16,3 +17,3 @@ var log = log4js.getLogger('stryker-cli');

.usage('<command> [options] [stryker.conf.js]')
.description("Possible commands: \n run: Run mutation testing\n\nOptional location to the stryker.conf.js file as last argument. That file should export a function which accepts a \"config\" object\n" + ConfigReader_1.CONFIG_SYNTAX_HELP)
.description("Possible commands: \n run: Run mutation testing\n init: Initalize Stryker for your project\n\nOptional location to the stryker.conf.js file as last argument. That file should export a function which accepts a \"config\" object\n" + ConfigReader_1.CONFIG_SYNTAX_HELP)
.arguments('<command> [stryker.conf.js]')

@@ -52,11 +53,15 @@ .action(function (cmd, config) {

}
if (program['logLevel']) {
log4js.setGlobalLogLevel(program['logLevel']);
}
var commands = {
run: function () { return new Stryker_1.default(program).runMutationTest().catch(function (err) {
init: function () { return new StrykerInitializer_1.default().initialize(); },
run: function () { return new Stryker_1.default(program).runMutationTest(); }
};
if (Object.keys(commands).indexOf(command) >= 0) {
commands[command]().catch(function (err) {
log.error("an error occurred", err);
process.exitCode = 1;
process.kill(process.pid, 'SIGINT');
}); }
};
if (Object.keys(commands).indexOf(command) >= 0) {
commands[command]();
});
}

@@ -63,0 +68,0 @@ else {

@@ -14,2 +14,3 @@ 'use strict';

var PluginLoader_1 = require("./PluginLoader");
var ScoreResultCalculator_1 = require("./ScoreResultCalculator");
var CoverageInstrumenter_1 = require("./coverage/CoverageInstrumenter");

@@ -74,2 +75,3 @@ var objectUtils_1 = require("./utils/objectUtils");

mutantResults = _b.sent();
this.reporter.onScoreCalculated(ScoreResultCalculator_1.default.calculate(mutantResults));
return [4 /*yield*/, this.wrapUpReporter()];

@@ -76,0 +78,0 @@ case 4:

/// <reference types="node" />
export declare const serialize: (obj: any) => string;
export declare function freezeRecursively(target: {
[customConfig: string]: any;
}): void;
export declare function freezeRecursively<T extends {
[prop: string]: any;
}>(target: T): T;
export declare function isPromise(input: any): input is Promise<any>;
export declare function filterEmpty<T>(input: (T | null | void)[]): T[];
export declare function deserialize(serializedJavascript: String): any;

@@ -8,0 +9,0 @@ export declare function isErrnoException(error: Error): error is NodeJS.ErrnoException;

@@ -13,2 +13,3 @@ "use strict";

});
return target;
}

@@ -20,2 +21,6 @@ exports.freezeRecursively = freezeRecursively;

exports.isPromise = isPromise;
function filterEmpty(input) {
return input.filter(function (item) { return item !== undefined && item !== null; });
}
exports.filterEmpty = filterEmpty;
function deserialize(serializedJavascript) {

@@ -22,0 +27,0 @@ // Don't use JSON.parse, as it does not allow for regexes or functions, etc

/// <reference types="node" />
declare var _default: {
declare const _default: {
createRandomFolder: (prefix: string) => string;

@@ -4,0 +4,0 @@ writeFile: (filename: string, data: string) => Promise<void>;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc