So I have an Angular project with around 30 unit tests, I want to validate my tests are actually testing something, so I want to add mutation tests. Stryker has been recommended to me. But I can't find any comprehensive guides for Angular mutation testing with Stryker.
I have stryker installed globally and I can run it on this repo: https://github.com/nicojs/angular-stryker-example
However when I try to add it to my code or vice versa I get serveral different errors, such as: to many open files, cant find ./src, unexpected token etc. Errors are never in my files, but probably in my configuration/installed packages.
So I want to know:
- What packages to install
- What commands to run
- What configurations to change
Current 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"
}
}
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,
})
};
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,
})
};
If you know another package for mutation testing that also would be good for me.
Aucun commentaire:
Enregistrer un commentaire