所以我有一个包含30个单元测试的Angular项目,我想验证我的测试实际上是在测试某些东西,因此我想添加突变测试。 Stryker已向我推荐。但是我找不到任何使用Stryker进行Angular突变测试的综合指南。
我已经在全球范围内安装了stryker,并且可以在此仓库中运行它:https://github.com/nicojs/angular-stryker-example
但是,当我尝试将其添加到我的代码中时,反之亦然,我会遇到服务器方面的不同错误,例如:许多打开的文件,找不到./src,意外的令牌等。错误从不在我的文件中,但可能在我的配置/安装的软件包。
所以我想知道:
当前package.json:
{
"name": "angular-truffle-box",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test --browsers PhantomJS --code-coverage",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "node patch.js",
"trufflecompile": "truffle compile"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.0",
"@angular/cdk": "^7.0.2",
"@angular/common": "6.1.7",
"@angular/compiler": "6.1.7",
"@angular/core": "6.1.7",
"@angular/forms": "6.1.7",
"@angular/http": "6.1.7",
"@angular/material": "^7.0.2",
"@angular/platform-browser": "6.1.7",
"@angular/platform-browser-dynamic": "6.1.7",
"@angular/platform-server": "6.1.7",
"@angular/router": "6.1.7",
"arr-flatten": "^1.1.0",
"core-js": "^2.5.4",
"ganache-cli": "6.2.3",
"hammerjs": "^2.0.8",
"intl": "^1.2.5",
"isarray": "^2.0.4",
"phantomjs": "^2.1.7",
"phantomjs-prebuilt": "^2.1.16",
"rxjs": "^6.3.2",
"tslint-sonarts": "^1.8.0",
"web3": "^1.0.0-beta.36",
"web3-utils": "^1.0.0-beta.36",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular-devkit/core": "0.8.1",
"@angular/cli": "^6.2.1",
"@angular/compiler-cli": "6.1.7",
"@angular/language-service": "6.1.7",
"@types/jasmine": "^2.8.6",
"@types/jasminewd2": "^2.0.3",
"@types/node": "^6.0.103",
"codelyzer": "^3.2.2",
"jasmine-core": "^2.99.1",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^1.4.2",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"protractor": "^5.4.1",
"protractor-console-plugin": "^0.1.1",
"stryker": "^0.6.1",
"stryker-api": "^0.5.0",
"stryker-html-reporter": "^0.4.1",
"stryker-jasmine": "^0.2.1",
"stryker-karma-runner": "^0.4.0",
"truffle-contract": "^3.0.4",
"ts-node": "^3.3.0",
"tslint": "^5.11.0",
"typescript": "^2.9.2"
}
}
stryker.conf.js:
module.exports = function(config) {
config.set({
mutate: [
"src/**/*.ts",
"!src/**/*.spec.ts",
"!src/test.ts",
"!src/environments/*.ts"
],
testFramework: 'jasmine',
testRunner: 'karma',
karmaConfigFile: 'karma.conf.js',
reporter: ['progress', 'clear-text', 'dots', 'html', 'event-recorder'],
coverageAnalysis: 'off',
plugins: ['stryker-karma-runner', 'stryker-html-reporter']
});
};
karma.conf.js
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
"src/**/*.ts",
"src/**/*.spec.ts",
//"src/test.ts",
//"src/environments/*.ts"
],
//reporters: ['spec'],
port: 9876,
colors: true,
logLevel: 'trace',
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity,
})
};
如果您知道另一个用于突变测试的软件包,这对我也很有益。