Skip to content

Commit

Permalink
feat(html-reporter): Score result as single source of truth (#341)
Browse files Browse the repository at this point in the history
* feat(html-reporter): Score result as single source of truth

Previously we've introduced a reporter event that should function as a single source of truth for all stryker score calculations. Now it is also used in the HTML reporter.

* Add properties `representsFile` and `path` to the `ScoreResult` interface, they are used in the html reporter
* Remove all calculations from the html reporter
* Replace dependency on `handlebarsjs` with `typed-html`
* Migrate all handlebarsjs templates to `typed-html` templates
* Refactor the tests, much cleaner now.
* Update protractor tests for new report
* fix(html-reporter): Use correct relative path. Fixes #335.
* test(HtmlReporter): Add unit tests and update the integration tests
  • Loading branch information
nicojs authored Aug 3, 2017
1 parent d66497d commit 47b3295
Show file tree
Hide file tree
Showing 58 changed files with 896 additions and 1,625 deletions.
4 changes: 2 additions & 2 deletions integrationTest/test/mocha-mocha/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = function (config) {
mutate: ['src/*.js'],
testFramework: 'mocha',
testRunner: 'mocha',
reporter: ['clear-text', 'html'],
reporter: ['clear-text', 'html', 'event-recorder'],
maxConcurrentTestRunners: 2,
port: 9264
});
};
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"link-parent-bin": "^0.1.1",
"mocha": "^3.2.0",
"nyc": "^10.2.0",
"protractor": "^5.1.1",
"protractor": "^5.1.2",
"rimraf": "^2.6.1",
"sinon": "^2.2.0",
"sinon-chai": "^2.10.0",
Expand All @@ -50,4 +50,4 @@
"test:stryker-api": "lerna run test --scope stryker",
"lerna-publish": "lerna publish --conventional-commits --yes --git-remote gh-publish"
}
}
}
12 changes: 11 additions & 1 deletion packages/stryker-api/src/report/ScoreResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ interface ScoreResult {
* The file or directory name of this score result node
*/
readonly name: string;


/**
* Full path to file or directory of this score result node
*/
readonly path: string;

/**
* True if this score result represents a file, false if it represents a directory
*/
readonly representsFile: boolean;

/**
* Any child directory/file score result nodes
* If this score result represents a file, the length will be 0
Expand Down
14 changes: 6 additions & 8 deletions packages/stryker-html-reporter/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
"type": "node",
"request": "launch",
"name": "Run ui tests",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run-script",
"uiTest"
"program": "${workspaceRoot}/../../node_modules/protractor/bin/protractor",
"args": [
"${workspaceRoot}/protractor.conf.js"
],
"port": 5858
"stopOnEntry": false,
"port": 5858,
"sourceMaps": true
},
{
"type": "node",
Expand Down
3 changes: 3 additions & 0 deletions packages/stryker-html-reporter/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"**/*.js": {
"when": "$(basename).ts"
},
"**/**.js": {
"when": "$(basename).tsx"
},
"**/*.d.ts": true,
"**/*.map": {
"when": "$(basename)"
Expand Down
11 changes: 11 additions & 0 deletions packages/stryker-html-reporter/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"args": ["start"],
"showOutput": "silent",
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
165 changes: 0 additions & 165 deletions packages/stryker-html-reporter/Gruntfile.js

This file was deleted.

10 changes: 6 additions & 4 deletions packages/stryker-html-reporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"typings": "src/index.d.ts",
"scripts": {
"clean": "rimraf \"+(test|src)/!(resources)/**/*+(.d.ts|.js|.map)\" coverage",
"prebuild": "npm run clean",
"build": "tsc -p . && node tasks/clientResources.js && browserify src/resources/stryker.js -o resources/stryker.js",
"postbuild": "tslint -p tsconfig.json",
"start": "tsc -w -p .",
"test": "nyc --check-coverage --lines 95 --functions 95 --branches 95 mocha \"test/helpers/*.js\" \"test/unit/*.js\" \"test/integration/*.js\""
"test": "nyc --check-coverage --lines 95 --functions 95 --branches 94 mocha \"test/helpers/*.js\" \"test/unit/*.js\" \"test/integration/*.js\""
},
"repository": {
"type": "git",
Expand All @@ -32,18 +33,19 @@
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-html-reporter#readme",
"dependencies": {
"file-url": "^2.0.0",
"handlebars": "^4.0.5",
"lodash": "^4.13.1",
"log4js": "^1.0.1",
"mkdirp": "^0.5.1",
"mz": "^2.5.0"
"mz": "^2.5.0",
"rimraf": "^2.6.1",
"typed-html": "^0.3.3"
},
"peerDependencies": {
"stryker-api": "^0.5.6"
},
"devDependencies": {
"@types/file-url": "^1.0.28",
"@types/handlebars": "^4.0.32",
"@types/rimraf": "0.0.28",
"@types/selenium-webdriver": "^3.0.3",
"bootstrap": "3.3.7",
"highlight.js": "^9.4.0",
Expand Down
9 changes: 0 additions & 9 deletions packages/stryker-html-reporter/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,4 @@ var config = {
}
};

if (process.env.TRAVIS) {
// Use the travis selenium server spawned in the container, only firefox is working atm
config.capabilities = {
browserName: 'firefox'
};
config.seleniumAddress = 'http://localhost:4444/wd/hub';
config.directConnect = false;
}

exports.config = config;
21 changes: 0 additions & 21 deletions packages/stryker-html-reporter/src/HandlebarsModel.ts

This file was deleted.

Loading

0 comments on commit 47b3295

Please sign in to comment.