stryker-api
Advanced tools
Comparing version 0.8.0 to 0.9.0
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
<a name="0.9.0"></a> | ||
# [0.9.0](https://github.com/stryker-mutator/stryker/compare/stryker-api@0.8.0...stryker-api@0.9.0) (2017-09-19) | ||
### Features | ||
* **typescript:** Add support for TypeScript mutation testing (#376) ([ba78168](https://github.com/stryker-mutator/stryker/commit/ba78168)) | ||
### BREAKING CHANGES | ||
* **typescript:** * Hoist the `Mutator` interface to a higher abstraction. With this interface it was possible to add mutators for specific ES5 AST nodes. As we're moving away from ES5, this plugin abstraction had to be hoisted to a higher level. It is no longer possible to plugin a specific ES5 node mutator. | ||
* Update `report` interface: Rename `MutantState.Error` => `MutantState.RuntimeError`. | ||
<a name="0.8.0"></a> | ||
@@ -7,0 +24,0 @@ # [0.8.0](https://github.com/stryker-mutator/stryker/compare/stryker-api@0.7.0...stryker-api@0.8.0) (2017-08-25) |
export { default as StrykerOptions } from './src/core/StrykerOptions'; | ||
export { default as Factory } from './src/core/Factory'; | ||
export { default as InputFile } from './src/core/InputFile'; | ||
export { BinaryFile, WebFile, TextFile, File, FileKind, FileDescriptor } from './src/core/File'; | ||
export { default as Position } from './src/core/Position'; | ||
@@ -5,0 +5,0 @@ export { default as Location } from './src/core/Location'; |
@@ -5,2 +5,4 @@ "use strict"; | ||
exports.Factory = Factory_1.default; | ||
var File_1 = require("./src/core/File"); | ||
exports.FileKind = File_1.FileKind; | ||
//# sourceMappingURL=core.js.map |
@@ -0,3 +1,3 @@ | ||
export { default as Mutant } from './src/mutant/Mutant'; | ||
export { default as Mutator } from './src/mutant/Mutator'; | ||
export { default as MutatorFactory } from './src/mutant/MutatorFactory'; | ||
export { IdentifiedNode, Identified } from './src/mutant/IdentifiedNode'; |
{ | ||
"name": "stryker-api", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "The api for the extendable JavaScript mutation testing framework Stryker", | ||
@@ -11,3 +11,3 @@ "scripts": { | ||
"postbuild": "tslint -p tsconfig.json", | ||
"test": "nyc --reporter=html --report-dir=reports/coverage --check-coverage --lines 90 --functions 68 --branches 64 mocha \"test/**/*.js\"" | ||
"test": "nyc --reporter=html --report-dir=reports/coverage --check-coverage --lines 90 --functions 68 --branches 63 mocha \"test/**/*.js\"" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": { |
@@ -15,2 +15,4 @@ import { StrykerOptions, InputFileDescriptor, MutationScoreThresholds } from '../../core'; | ||
testFramework: string; | ||
mutator: string; | ||
transpilers: string[]; | ||
maxConcurrentTestRunners: number; | ||
@@ -17,0 +19,0 @@ thresholds: MutationScoreThresholds; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Config = (function () { | ||
var Config = /** @class */ (function () { | ||
function Config() { | ||
@@ -12,2 +12,4 @@ this.logLevel = 'info'; | ||
this.coverageAnalysis = 'perTest'; | ||
this.mutator = 'es5'; | ||
this.transpilers = []; | ||
this.maxConcurrentTestRunners = Infinity; | ||
@@ -14,0 +16,0 @@ this.thresholds = { |
@@ -10,3 +10,3 @@ "use strict"; | ||
*/ | ||
var ConfigEditorFactory = (function (_super) { | ||
var ConfigEditorFactory = /** @class */ (function (_super) { | ||
tslib_1.__extends(ConfigEditorFactory, _super); | ||
@@ -13,0 +13,0 @@ function ConfigEditorFactory() { |
@@ -8,3 +8,3 @@ "use strict"; | ||
*/ | ||
var Factory = (function () { | ||
var Factory = /** @class */ (function () { | ||
/** | ||
@@ -11,0 +11,0 @@ * Creates a new Factory. |
/** | ||
* A specific spot in the source code. | ||
* A specific spot in the source code based on line and column. | ||
* Stryker uses zero-based indexes. So the first character in a file is at line 0, column 0. | ||
*/ | ||
@@ -4,0 +5,0 @@ interface Position { |
@@ -10,6 +10,7 @@ import InputFileDescriptor from './InputFileDescriptor'; | ||
* * `string`: A globbing expression used for selecting the files needed to run the tests. | ||
* * { pattern: 'pattern', included: true } : | ||
* * { pattern: 'pattern', included: true, mutated: false, transpiled: true }: | ||
* * The `pattern` property is mandatory and contains the globbing expression used for selecting the files | ||
* * The `included` property is optional and determines whether or not this file should be loaded initially by the test-runner (default: true) | ||
* * The `mutated` property is optional and determines whether or not this file should be targeted for mutations (default: false) | ||
* * The `transpiled` property is optional and determines whether or not this file should be transpiled by a transpiler (see `transpilers` config option) (default: true) | ||
* | ||
@@ -43,2 +44,26 @@ * @example | ||
/** | ||
* The name of the mutant generator to use to generate mutants based on your input file. | ||
* This is often dependent on the language of your source files. | ||
* For example: 'es5', 'typescript' | ||
*/ | ||
mutator?: string; | ||
/** | ||
* The names of the transpilers to use (in order). Default: []. | ||
* A transpiler in this context is a plugin that can transform input files (source code) | ||
* before testing. | ||
* | ||
* Example use cases: | ||
* * You need to transpile typescript before testing it in nodejs | ||
* * You want to bundle nodejs code before testing it in the browser. | ||
* | ||
* The order of your defined transpilers is important, as each transpiler | ||
* will be fead the output files of the previous transpiler. For example: | ||
* | ||
* foo.ts ==> Typescript ==> foo.js ==> Webpack ==> foobar.js | ||
* bar.ts ==> Transpiler ==> bar.js ==> Transpiler | ||
* | ||
* Transpilers should ignore files marked with `transpiled = false`. See `files` array. | ||
*/ | ||
transpilers?: string[]; | ||
/** | ||
* Thresholds for mutation score. | ||
@@ -45,0 +70,0 @@ */ |
@@ -1,22 +0,5 @@ | ||
import { IdentifiedNode } from './IdentifiedNode'; | ||
/** | ||
* Represents a class which can mutate parts of an Abstract Syntax Tree. | ||
*/ | ||
interface Mutator { | ||
/** | ||
* The name of the Mutator which may be used by reporters. | ||
*/ | ||
name: string; | ||
/** | ||
* Applies the Mutator to a Node. This can result in one or more mutated Nodes, or null if no mutation was applied. | ||
* This method will be called on every node of the abstract syntax tree, | ||
* implementing mutators should decide themselves if they want to mutate this specific node. | ||
* If the mutator wants to mutate the node, it should return a clone of the node with mutations, | ||
* otherwise null. | ||
* @param node A FROZEN Node which could be cloned and mutated. | ||
* @param copy A function to create a copy of an object. | ||
* @returns An array of mutated Nodes. | ||
*/ | ||
applyMutations(node: IdentifiedNode, copy: <T extends IdentifiedNode>(obj: T, deep?: boolean) => T): void | IdentifiedNode | IdentifiedNode[]; | ||
import { File } from '../../core'; | ||
import Mutant from './Mutant'; | ||
export default interface Mutator { | ||
mutate(inputFiles: File[]): Mutant[]; | ||
} | ||
export default Mutator; |
import Mutator from './Mutator'; | ||
import { Factory } from '../../core'; | ||
import { Config } from '../../config'; | ||
declare namespace MutatorFactory { | ||
@@ -7,4 +8,4 @@ /** | ||
*/ | ||
function instance(): Factory<void, Mutator>; | ||
function instance(): Factory<Config, Mutator>; | ||
} | ||
export default MutatorFactory; |
@@ -8,8 +8,8 @@ "use strict"; | ||
/** | ||
* Represents a Factory for TestFrameworks. | ||
* Represents a Factory for Mutators. | ||
*/ | ||
var MutatorFactory = (function (_super) { | ||
var MutatorFactory = /** @class */ (function (_super) { | ||
tslib_1.__extends(MutatorFactory, _super); | ||
function MutatorFactory() { | ||
return _super.call(this, 'mutator') || this; | ||
return _super.call(this, 'mutant-generator') || this; | ||
} | ||
@@ -16,0 +16,0 @@ return MutatorFactory; |
@@ -5,5 +5,5 @@ interface MatchedMutant { | ||
readonly timeSpentScopedTests: number; | ||
readonly filename: string; | ||
readonly fileName: string; | ||
readonly replacement: string; | ||
} | ||
export default MatchedMutant; |
@@ -19,6 +19,25 @@ declare enum MutantStatus { | ||
/** | ||
* The status of a mutant of which the tests resulted in an Error | ||
* The status of a mutant of which the tests resulted in a runtime error. | ||
* | ||
* For example: the following piece of javascript code will result in a runtime error: | ||
* | ||
* ```javascript | ||
* const fs = require('f' - 's'); // mutated code | ||
* ``` | ||
* | ||
* Mutants that result in a runtime error are not taken into account during score calculation. | ||
*/ | ||
Error = 4, | ||
RuntimeError = 4, | ||
/** | ||
* The status of a mutant which could not be transpiled. | ||
* For example: the following piece of typescript code will give a TranspileError: | ||
* | ||
* ```typescript | ||
* const a: 5 = 0; // mutated code | ||
* ``` | ||
* | ||
* Mutants that result in a TranspileError are not taken into account during score calculation. | ||
*/ | ||
TranspileError = 5, | ||
} | ||
export default MutantStatus; |
@@ -22,7 +22,26 @@ "use strict"; | ||
/** | ||
* The status of a mutant of which the tests resulted in an Error | ||
* The status of a mutant of which the tests resulted in a runtime error. | ||
* | ||
* For example: the following piece of javascript code will result in a runtime error: | ||
* | ||
* ```javascript | ||
* const fs = require('f' - 's'); // mutated code | ||
* ``` | ||
* | ||
* Mutants that result in a runtime error are not taken into account during score calculation. | ||
*/ | ||
MutantStatus[MutantStatus["Error"] = 4] = "Error"; | ||
MutantStatus[MutantStatus["RuntimeError"] = 4] = "RuntimeError"; | ||
/** | ||
* The status of a mutant which could not be transpiled. | ||
* For example: the following piece of typescript code will give a TranspileError: | ||
* | ||
* ```typescript | ||
* const a: 5 = 0; // mutated code | ||
* ``` | ||
* | ||
* Mutants that result in a TranspileError are not taken into account during score calculation. | ||
*/ | ||
MutantStatus[MutantStatus["TranspileError"] = 5] = "TranspileError"; | ||
})(MutantStatus || (MutantStatus = {})); | ||
exports.default = MutantStatus; | ||
//# sourceMappingURL=MutantStatus.js.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
*/ | ||
var ReporterFactory = (function (_super) { | ||
var ReporterFactory = /** @class */ (function (_super) { | ||
tslib_1.__extends(ReporterFactory, _super); | ||
@@ -13,0 +13,0 @@ function ReporterFactory() { |
@@ -39,7 +39,12 @@ /** | ||
/** | ||
* The total number of mutants that caused an error. | ||
* The total number of mutants that caused an error during testing. | ||
* These didn't effect the mutation score, as they are treated as false positives. | ||
*/ | ||
readonly errors: number; | ||
readonly runtimeErrors: number; | ||
/** | ||
* The total number of mutants that caused an error during transpiling. | ||
* These didn't effect the mutation score. as they are treated as false positives. | ||
*/ | ||
readonly transpileErrors: number; | ||
/** | ||
* The total number of mutants that were detected, meaning either killed or caused a time out. | ||
@@ -55,5 +60,14 @@ * `killed + timed out` | ||
/** | ||
* The total number of invalid mutants. | ||
* `runtimeErrors + transpileErrors` | ||
*/ | ||
readonly totalInvalid: number; | ||
/** | ||
* Total number of valid mutants. | ||
* `totalDetected + totalUndetected` | ||
*/ | ||
readonly totalValid: number; | ||
/** | ||
* The total number of mutants. | ||
* Excluding any mutants that caused an error as they are treated as false positives. | ||
* `killed + timed out + survived + no coverage` | ||
* `totalInvalid + totalValid` | ||
*/ | ||
@@ -63,3 +77,3 @@ readonly totalMutants: number; | ||
* The total number of mutants tested in an area that had code coverage result | ||
* `killed + timed out + survived` | ||
* `totalDetected + survived` | ||
*/ | ||
@@ -69,3 +83,3 @@ readonly totalCovered: number; | ||
* The total percentage of mutants that were killed. | ||
* `totalDetected / totalMutants * 100`, | ||
* `totalDetected / totalValid * 100`, | ||
*/ | ||
@@ -72,0 +86,0 @@ readonly mutationScore: number; |
@@ -10,3 +10,3 @@ "use strict"; | ||
*/ | ||
var TestFrameworkFactory = (function (_super) { | ||
var TestFrameworkFactory = /** @class */ (function (_super) { | ||
tslib_1.__extends(TestFrameworkFactory, _super); | ||
@@ -13,0 +13,0 @@ function TestFrameworkFactory() { |
@@ -1,2 +0,2 @@ | ||
import { StrykerOptions, InputFile } from '../../core'; | ||
import { StrykerOptions, FileDescriptor } from '../../core'; | ||
/** | ||
@@ -9,3 +9,3 @@ * Represents an options object to configure a TestRunner. | ||
*/ | ||
files: InputFile[]; | ||
files: FileDescriptor[]; | ||
/** | ||
@@ -12,0 +12,0 @@ * Represents a free port which the test runner can choose to use |
@@ -40,3 +40,3 @@ /// <reference types="node" /> | ||
* Optional. When implemented, will be called before runs are done on this test runner. | ||
* @returns A promise if stuff is initialized asyncronously, runs will not start until the promise is resolved. | ||
* @returns A promise if stuff is initialized asynchronously, runs will not start until the promise is resolved. | ||
* Otherwise void | ||
@@ -53,3 +53,3 @@ */ | ||
* Optional. When implemented, will be called before the test runner's process is killed. | ||
* @returns A promise if stuff is destroyed asyncronously, the runners process will not end until the promise is resolved. | ||
* @returns A promise if stuff is destroyed asynchronously, the runners process will not end until the promise is resolved. | ||
* Otherwise void | ||
@@ -56,0 +56,0 @@ */ |
@@ -10,3 +10,3 @@ "use strict"; | ||
*/ | ||
var TestRunnerFactory = (function (_super) { | ||
var TestRunnerFactory = /** @class */ (function (_super) { | ||
tslib_1.__extends(TestRunnerFactory, _super); | ||
@@ -13,0 +13,0 @@ function TestRunnerFactory() { |
70888
94
1298