-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c1b06b6
Showing
20 changed files
with
1,956 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
service_name: travis-ci | ||
repo_token: X7OWjKpfXN6CodaSj2fYyoENbn7zccjFx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "standard" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea | ||
coverage | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.git | ||
.gitignore | ||
.editorconfig | ||
.idea | ||
.npmignore | ||
.vscode | ||
coverage | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
sudo: false | ||
language: node_js | ||
cache: | ||
directories: | ||
- ~/.npm | ||
notifications: | ||
email: false | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' | ||
script: | ||
- npm run coverage | ||
after_success: | ||
- test `node --version | cut -c 2` -eq 8 && npm run coveralls | ||
branches: | ||
except: | ||
- /^v\d+\.\d+\.\d+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Ferdinand Prantl | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
[![npm version](https://badge.fury.io/js/karma-summary-reporter.svg)](http://badge.fury.io/js/karma-summary-reporter) | ||
[![Build Status](https://travis-ci.org/dgarlitt/karma-summary-reporter.svg)](https://travis-ci.org/dgarlitt/karma-summary-reporter) | ||
[![Coverage Status](https://coveralls.io/repos/dgarlitt/karma-summary-reporter/badge.svg?branch=master)](https://coveralls.io/r/dgarlitt/karma-summary-reporter?branch=master) | ||
[![Dependency Status](https://david-dm.org/dgarlitt/karma-summary-reporter.svg)](https://david-dm.org/dgarlitt/karma-summary-reporter) | ||
|
||
karma-summary-reporter | ||
====================== | ||
|
||
The summary reporter originated with a similar idea behind the [Nyan Cat reporter] - do not print information about every successful test or failing test immediately, like the [Mocha reporter] does it. Print only test count statistics during the test run and summary about failing tests at the end. Unlike the Nyan Cat reporter, this reporter prints the progress statistics on one line only. It takes less space and if the terminal application prevents moving the cursor up, the screen is not covered by garbage. | ||
|
||
Examples | ||
-------- | ||
|
||
A successful test run: | ||
|
||
```txt | ||
65 total 57 passed 0 failed 8 skipped | ||
``` | ||
|
||
A test run, which ended with a runtime error at the very beginning, because a code module has been missing: | ||
|
||
```txt | ||
0 total 0 passed 0 failed 0 skipped | ||
HeadlessChrome 0.0.0 (Linux 0.0.0) | ||
Error: Script error for "jquery", needed by: /base/tests/main.spec.js | ||
http://requirejs.org/docs/errors.html#scripterror | ||
at makeError (http://localhost:9876/base/node_modules/requirejs/require.js?242a935a7049803efaaa891de70075a8d6432d9b:168:17) | ||
at HTMLScriptElement.onScriptError (http://localhost:9876/base/node_modules/requirejs/require.js?242a935a7049803efaaa891de70075a8d6432d9b:1738:36) | ||
``` | ||
|
||
A test run, which ended with one test failure: | ||
|
||
```txt | ||
65 total 56 passed 1 failed 8 skipped | ||
Failed Tests: | ||
main page | ||
renders page loading time | ||
HeadlessChrome 0.0.0 (Linux 0.0.0) | ||
1) Expected '0' to equal '2'. | ||
at UserContext.<anonymous> (tests/main.spec.js:78:67) | ||
``` | ||
|
||
The real console output is colourful. | ||
|
||
Installation | ||
------------ | ||
|
||
Installation is simple using npm, just run the following command: | ||
|
||
```sh | ||
npm install --save-dev karma-summary-reporter | ||
``` | ||
|
||
Since this follows Karma's plugin naming convention, that's all there is to it! | ||
|
||
Now, run your tests and enjoy: | ||
|
||
```sh | ||
karma start path/to/karma.conf.js --reporters summary | ||
``` | ||
|
||
Options | ||
------- | ||
|
||
If you want to suppress various output parts, flip the corresponding `suppress*` flag in the reporter options. | ||
|
||
```js | ||
// karma.conf.js | ||
module.exports = function(config) { | ||
config.set({ | ||
// Choose the reporter | ||
reporters: ['summary'], | ||
|
||
// Reporter options | ||
summaryReporter: { | ||
// Suppress the error report at the end of the test run. | ||
suppressErrorReport: true, // default is false | ||
|
||
// Suppress the red background on errors in the error | ||
// report at the end of the test run. | ||
suppressErrorHighlighting: true, // default is false | ||
|
||
// Suppress the browser console log at the end of the test run. | ||
suppressBrowserLogs: true, // default is false | ||
|
||
// Only render the graphic after all tests have finished. | ||
// This is ideal for using this reporter in a continuous | ||
// integration environment. | ||
renderOnRunCompleteOnly: true // default is false | ||
} | ||
}); | ||
}; | ||
``` | ||
|
||
Contributing | ||
------------ | ||
|
||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using the npm script commands. | ||
|
||
License | ||
------- | ||
|
||
Copyright (c) 2018 Ferdinand Prantl | ||
|
||
Licensed under the MIT license. | ||
|
||
[Nyan Cat reporter]: https://github.com/prantlf/karma-nyan-reporter | ||
[Mocha reporter]: https://github.com/litixsoft/karma-mocha-reporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
const Summary = require('./lib/summary') | ||
|
||
Summary.$inject = ['baseReporterDecorator', 'formatError', 'config'] | ||
|
||
module.exports = { | ||
'reporter:summary': ['type', Summary] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use strict' | ||
|
||
let types = require('./types') | ||
|
||
let DataStore = function () { | ||
let data = [] | ||
|
||
this.getData = function () { | ||
return data | ||
} | ||
} | ||
|
||
DataStore.prototype.save = function (browser, result) { | ||
if (!result.success && !result.skipped && result.suite.length > 0) { | ||
let suite = this.findSuiteInResult(result) | ||
|
||
this.saveResultToSuite(suite, browser, result) | ||
} | ||
} | ||
|
||
DataStore.prototype.saveResultToSuite = function (suite, browser, result) { | ||
suite.tests = (!suite.tests) ? [] : suite.tests | ||
let test = this.findTestByName(suite.tests, result.description) | ||
test.depth = suite.depth + 1 | ||
|
||
let browserInfo = this.findBrowserByName(test.browsers, browser.name) | ||
browserInfo.depth = test.depth + 1 | ||
|
||
if (result.log && result.log[0] !== null) { | ||
browserInfo.errors = result.log[0].split('\n') | ||
} | ||
} | ||
|
||
DataStore.prototype.findSuiteInResult = function (result) { | ||
let suite | ||
let self = this | ||
let searchArray = self.getData() | ||
|
||
result.suite.forEach(function (suiteName, i) { | ||
suite = self.findSuiteByName(searchArray, suiteName) | ||
suite.depth = i | ||
|
||
suite.suites = (!suite.suites) ? [] : suite.suites | ||
searchArray = suite.suites | ||
}) | ||
|
||
return suite | ||
} | ||
|
||
DataStore.prototype.findByName = function (arr, name, Constructor) { | ||
let it | ||
// Look through the array for an object with a | ||
// 'name' property that matches the 'name' arg | ||
arr.every(function (el) { | ||
if (el.name === name) { | ||
it = el | ||
return false | ||
} | ||
return true | ||
}) | ||
|
||
// If a matching object is not found, create a | ||
// new one and push it to the provided array | ||
if (!it) { | ||
it = new Constructor(name) | ||
arr.push(it) | ||
} | ||
|
||
// return the object | ||
return it | ||
} | ||
|
||
DataStore.prototype.findSuiteByName = function (arr, name) { | ||
return this.findByName(arr, name, types.Suite) | ||
} | ||
|
||
DataStore.prototype.findTestByName = function (arr, name) { | ||
return this.findByName(arr, name, types.Test) | ||
} | ||
|
||
DataStore.prototype.findBrowserByName = function (arr, name) { | ||
return this.findByName(arr, name, types.Browser) | ||
} | ||
|
||
exports.getInstance = function () { return new DataStore() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
'use strict' | ||
|
||
let clc = require('cli-color') | ||
|
||
let counter = 0 | ||
let tab = 3 | ||
let tabs = function (depth) { | ||
return clc.right(depth * tab + 1) | ||
} | ||
|
||
let errorHighlightingEnabled = true | ||
|
||
exports.suppressErrorHighlighting = function () { | ||
errorHighlightingEnabled = false | ||
} | ||
|
||
let errorFormatterMethod = function (error) { | ||
return error.replace(/(\?.+?:)/, ':').trim() | ||
} | ||
|
||
exports.setErrorFormatterMethod = function (formatterMethod) { | ||
errorFormatterMethod = formatterMethod | ||
} | ||
|
||
function Suite (name) { | ||
this.name = name.trim() | ||
this.depth = 0 | ||
this.suites = [] | ||
this.tests = [] | ||
} | ||
|
||
Suite.prototype.toString = function () { | ||
let out = [] | ||
|
||
if (this.depth === 0) { | ||
out.push(tabs(this.depth) + clc.white.underline(this.name)) | ||
} else { | ||
out.push(tabs(this.depth) + clc.white(this.name)) | ||
} | ||
|
||
this.tests.forEach(function (test) { | ||
out.push(test.toString().trim()) | ||
out.push('') | ||
}) | ||
|
||
this.suites.forEach(function (suite) { | ||
out.push(suite.toString().trim()) | ||
out.push('') | ||
}) | ||
|
||
out.push('') | ||
out.push('') | ||
|
||
out = out.join('\n') | ||
|
||
return out | ||
} | ||
|
||
function Test (name) { | ||
this.name = name.trim() | ||
this.depth = 0 | ||
this.browsers = [] | ||
} | ||
|
||
Test.prototype.toString = function () { | ||
let out = [] | ||
|
||
out.push(tabs(this.depth) + clc.red(this.name)) | ||
|
||
this.browsers.forEach(function (browser) { | ||
out.push(browser.toString().trim()) | ||
}) | ||
|
||
return out.join('\n') | ||
} | ||
|
||
function Browser (name) { | ||
this.name = name.trim() | ||
this.depth = 0 | ||
this.errors = [] | ||
} | ||
|
||
Browser.prototype.toString = function () { | ||
let depth = this.depth | ||
let out = [] | ||
|
||
out.push(tabs(this.depth) + clc.yellow(this.name)) | ||
|
||
this.errors.forEach(function (error, i) { | ||
error = error.trim() | ||
if (i === 0) { | ||
out.push(tabs(depth + 1) + (++counter) + ') ' + clc.redBright(error)) | ||
} else { | ||
error = errorFormatterMethod(error).trim() | ||
|
||
if (error.length) { | ||
if (error.indexOf('node_modules/') < 0 && errorHighlightingEnabled) { | ||
error = clc.black.bgRed(error) | ||
} else { | ||
error = clc.blackBright(error) | ||
} | ||
out.push(tabs(depth + 2) + error) | ||
} | ||
} | ||
}) | ||
|
||
return out.join('\n') | ||
} | ||
|
||
exports.Suite = Suite | ||
exports.Test = Test | ||
exports.Browser = Browser |
Oops, something went wrong.