1.0.3 • Published 7 years ago
karma-taggedjson-reporter v1.0.3
karma-taggedJSON-reporter
a simple JSON reporter that reads tag
JSON reporter for Karma
Installation
npm install karma-taggedjson-reporter --save-dev
Usage
Use it as a reporter
// karma.conf.js
module.exports = function(config) {
// ...
// json reporter directly output stringified json
reporters: ['taggedJSON'],
taggedJSONReporter: {
outputFile: './path/to/your-reports.json' // defaults to none
}
// ...
};
How to tag?
describe ("Some Test", function () {
it ("Add a tag here with double '@' sign @@likethis", function (done) {
expect(true).to.be.false;
//the tag will be captured only if it fails
});
});
Basically, I check for the description of each spec and process for '@@' in it. :)
Sample Output data
{
"reports": [{
"browser": "Chrome 54.0.2840 (Windows 10 0.0.0)",
"success": [{
"id": "",
"description": "Should fail",
"suite": ["Testing"],
"success": true,
"skipped": false,
"time": 0,
"log": [],
"assertionErrors": [],
"startTime": 1495427961282,
"endTime": 1495427961284
}],
"failure": {
"@@impt": [{
"id": "",
"description": "Is Important @@impt",
"suite": ["Another Test"],
"success": false,
"skipped": false,
"time": 2,
"log": ["AssertionError: expected true to be false"],
"assertionErrors": [{
"name": "AssertionError",
"message": "expected true to be false",
"showDiff": false
}],
"startTime": 1495427961285,
"endTime": 1495427961288,
"tag": "@@impt"
}],
"normal": [{
"id": "",
"description": "Is not so Important",
"suite": ["Yet Another Test"],
"success": false,
"skipped": false,
"time": 0,
"log": ["AssertionError: expected true to be false"],
"assertionErrors": [{
"name": "AssertionError",
"message": "expected true to be false",
"showDiff": false
}],
"startTime": 1495427961289,
"endTime": 1495427961289,
"tag": "normal"
}]
}
}]
}