Socket
Socket
Sign inDemoInstall

js-reporters

Package Overview
Dependencies
0
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.2.1

10

CHANGELOG.md

@@ -0,1 +1,11 @@

1.2.1 / 2017-07-04
==================
* Reporter: Print "actual:", "expected:" even if they are undefined
* Reporter: Drop accidentally committed console.warn()
* Readme: Use canonical path to QUnit repository (#99)
* Readme: Add note about potential assertion memory leaks
* Readme: Improve formatting of bullets
* Release: Add documentation for release process
1.2.0 / 2017-03-22

@@ -2,0 +12,0 @@ ==================

14

dist/js-reporters.js
/**
* JsReporters 1.2.0
* JsReporters 1.2.1
* https://github.com/js-reporters

@@ -9,3 +9,3 @@ *

*
* Date: Wed Mar 22 2017
* Date: Tue Jul 04 2017
*/

@@ -1581,8 +1581,10 @@

if (error.actual) {
console.log(' actual: ' + JSON.stringify(error.actual, null, 2));
if (error.hasOwnProperty('actual')) {
var actualStr = error.actual !== undefined ? JSON.stringify(error.actual, null, 2) : 'undefined';
console.log(' actual: ' + actualStr);
}
if (error.expected) {
console.log(' expected: ' + JSON.stringify(error.expected, null, 2));
if (error.hasOwnProperty('expected')) {
var expectedStr = error.expected !== undefined ? JSON.stringify(error.expected, null, 2) : 'undefined';
console.log(' expected: ' + expectedStr);
}

@@ -1589,0 +1591,0 @@

@@ -49,8 +49,10 @@ import chalk from 'chalk'

if (error.actual) {
console.log(` actual: ${JSON.stringify(error.actual, null, 2)}`)
if (error.hasOwnProperty('actual')) {
var actualStr = error.actual !== undefined ? JSON.stringify(error.actual, null, 2) : 'undefined'
console.log(` actual: ${actualStr}`)
}
if (error.expected) {
console.log(` expected: ${JSON.stringify(error.expected, null, 2)}`)
if (error.hasOwnProperty('expected')) {
var expectedStr = error.expected !== undefined ? JSON.stringify(error.expected, null, 2) : 'undefined'
console.log(` expected: ${expectedStr}`)
}

@@ -57,0 +59,0 @@

{
"name": "js-reporters",
"version": "1.2.0",
"version": "1.2.1",
"description": "common reporter interface for javascript testing frameworks",

@@ -49,3 +49,14 @@ "main": "dist/js-reporters.js",

"webpack": "^1.0.0"
},
"commitplease": {
"components": [
"Build",
"Changelog",
"Readme",
"Release",
"Reporter",
"Test",
"Docs"
]
}
}

@@ -8,3 +8,3 @@ # js-reporters

The Common Reporter Interface (CRI) for JavaScript Unit Testing Frameworks
The Common Reporter Interface (CRI) for JavaScript Unit Testing Frameworks.

@@ -15,3 +15,2 @@ | Avoid this: | Do this: |

## Centralized Discussions

@@ -21,18 +20,17 @@

## Background
We on the [QUnit](http://qunitjs.com/) team have been [discussing](https://github.com/jquery/qunit/issues/531) the possibility of working with other JS test frameworks, especially those that can be run client-side (e.g. Mocha, Jasmine, Intern, Buster, etc.), to agree upon a "Common Reporter Interface" so that we could hopefully share Reporter plugins between testing frameworks. This would also benefit high-level consumers of the frameworks such as Karma, BrowserStack, SauceLabs, Testling, etc.
We on the [QUnit](http://qunitjs.com/) team have been [discussing](https://github.com/qunitjs/qunit/issues/531) the possibility of working with other JS test frameworks, especially those that can be run client-side (e.g. Mocha, Jasmine, Intern, Buster, etc.), to agree upon a "Common Reporter Interface" so that we could hopefully share Reporter plugins between testing frameworks. This would also benefit high-level consumers of the frameworks such as Karma, BrowserStack, SauceLabs, Testling, etc.
This would most likely come in the form of:
- a common Reporter API/Interface, e.g.
- an EventEmitter interface (`.on(...)`/`.off(...)`) _**OR**_ an object with standard "hook" properties
- _maybe_ a standard-ish way to register a Reporter, e.g. `MyLib.addReporter(x)`, `MyLib.reporter = x;`, etc.
- a minimum viable set of standardly-named events
- an associated standard set of data/details provided for each event
- a minimum viable set of standard test status types (e.g. pass, fail, skip, todo, pending, etc.)
- updating all participating test frameworks to support this new common Reporter interface
Would _you_ be interested in discussing this with us further? Please join in!
- a common Reporter API/Interface, e.g.
- an EventEmitter interface (`.on(...)`/`.off(...)`) _**OR**_ an object with standard "hook" properties
- _maybe_ a standard-ish way to register a Reporter, e.g. `MyLib.addReporter(x)`, `MyLib.reporter = x;`, etc.
- a minimum viable set of standardly-named events
- an associated standard set of data/details provided for each event
- a minimum viable set of standard test status types (e.g. pass, fail, skip, todo, pending, etc.)
- updating all participating test frameworks to support this new common Reporter interface
Would _you_ be interested in discussing this with us further? Please join in!

@@ -45,10 +43,9 @@ ## Draft Proposal

- `runStart`: Indicates the beginning of a testsuite, triggered just once.
- `suiteStart`: Triggered at the start of each group of tests within a testsuite.
- `testStart`: Triggered at the start of each test.
- `testEnd`: Triggered at the end of each test.
- `suiteEnd`: Triggered at the end of each group of tests within a testsuite.
- `runEnd`: Indicates the end of a testsuite, triggered just once.
- `runStart`: Indicates the beginning of a testsuite, triggered just once.
- `suiteStart`: Triggered at the start of each group of tests within a testsuite.
- `testStart`: Triggered at the start of each test.
- `testEnd`: Triggered at the end of each test.
- `suiteEnd`: Triggered at the end of each group of tests within a testsuite.
- `runEnd`: Indicates the end of a testsuite, triggered just once.
#### Selection Criteria

@@ -58,5 +55,5 @@

- These use the most common terms across a selection of frameworks, as gathered in [#1](https://github.com/js-reporters/js-reporters/issues/1#issuecomment-54841874)
- It uses names that are valid JavaScript identifiers, which allows using those as keys in JSON and avoids the need to quote keys in regular JS objects or function calls.
- It doesn't overlap with any known existing events, so introducing these could be done in parallel to the existing API in each framework, optionally deprecating and eventually removing the previous API.
- These use the most common terms across a selection of frameworks, as gathered in [#1](https://github.com/js-reporters/js-reporters/issues/1#issuecomment-54841874)
- It uses names that are valid JavaScript identifiers, which allows using those as keys in JSON and avoids the need to quote keys in regular JS objects or function calls.
- It doesn't overlap with any known existing events, so introducing these could be done in parallel to the existing API in each framework, optionally deprecating and eventually removing the previous API.

@@ -74,7 +71,8 @@ #### Reporting Order

The structures have been divided in two parts, a start part and an end part:
- SuiteStart
- SuiteEnd
- TestStart
- TestEnd
- SuiteStart
- SuiteEnd
- TestStart
- TestEnd
For `testStart` and `testEnd`, the corresponding TestStart, respectively TestEnd, object is passed to the reporter. The same applies to `suiteStart` and `suiteEnd` where the matching SuiteStart/SuiteEnd object is passed to the reporter. For `runStart` and `runEnd` a "global" suite object is passed to the reporter, this suite wraps all other top-level user defined suites as its child suites, it will be reffered to as `globalSuite`.

@@ -85,11 +83,11 @@

- **SuiteStart**: `Object` - A SuiteStart is a collection of test-starts and potentially other suite-starts, emitted before the suite have been executed, which means before executing any of its tests and child suites.
- **name**: `String|undefined` - name of the suite, will be `undefined` only for the `globalSuite`.
- **fullname**: `Array` - array of strings containing the name of the suite and the names of all its suites ancestors.
- **tests**: `Array` - array containing all tests that directly belong to the suite (but not to a child suite).
- **childSuites**: `Array` - array with all direct subsuites.
- **testCounts**: `Object` - contains the total number of tests in the suite, including the tests of the child suites.
- **name**: `String|undefined` - name of the suite, will be `undefined` only for the `globalSuite`.
- **fullname**: `Array` - array of strings containing the name of the suite and the names of all its suites ancestors.
- **tests**: `Array` - array containing all tests that directly belong to the suite (but not to a child suite).
- **childSuites**: `Array` - array with all direct subsuites.
- **testCounts**: `Object` - contains the total number of tests in the suite, including the tests of the child suites.
- **total**: `Number` - total number of tests
- **SuiteEnd**: `Object` - A SuiteEnd is a collection of test-ends and potentially other suite-ends, emitted after the suite has been executed, which means that all its tests and child suites have been also executed. **In addition** to the properties of `SuiteStart`, `SuiteEnd` also has the following properties:
- **status**: `String` - summarized status of the suite.
- **status**: `String` - summarized status of the suite.
- `failed`, if at least one test in the suite or in its child suites has failed.

@@ -99,3 +97,3 @@ - `skipped`, if all tests in the suite and in its child suites are skipped (and there is at least one skipped test).

- `passed`, if there is at least one passed test in the suite or in its child suites and all other tests are skipped or todo, or if there are no tests in the suite.
- **testCounts**: `Object` - contains how many tests have passed, failed etc. including the tests of child suites.
- **testCounts**: `Object` - contains how many tests have passed, failed etc. including the tests of child suites.
- **passed**: `Number` - number of passed tests.

@@ -106,3 +104,3 @@ - **failed**: `Number` - number of failed tests.

- **total**: `Number` - total number of tests, the sum of the above properties must equal this one.
- **runtime**: `Number` - execution time of the whole suite in milliseconds (including child suites).
- **runtime**: `Number` - execution time of the whole suite in milliseconds (including child suites).

@@ -112,11 +110,11 @@ The above `suite properties` apply also for the `globalSuite`.

- **TestStart**: `Object` - A test-start holds basic information on a single test/spec before its execution.
- **name**: `String` - name of the test.
- **suiteName**: `String` - name of the suite the test belongs to.
- **fullName**: `Array` - array of strings containing the name of the test and the names of all its suites ancestors.1
- **name**: `String` - name of the test.
- **suiteName**: `String` - name of the suite the test belongs to.
- **fullName**: `Array` - array of strings containing the name of the test and the names of all its suites ancestors.1
- **TestEnd**: `Object` - A test-end holds basic information on a single test/spec after its execution.
- **name**: `String` - name of the test.
- **suiteName**: `String` - name of the suite the test belongs to.
- **fullName**: `Array` - array of strings containing the name of the test and the names of all its suites ancestors.
- **status**: `String` - result of the test. Can be:
- **name**: `String` - name of the test.
- **suiteName**: `String` - name of the suite the test belongs to.
- **fullName**: `Array` - array of strings containing the name of the test and the names of all its suites ancestors.
- **status**: `String` - result of the test. Can be:
- `passed`, if all assertions have passed.

@@ -126,5 +124,5 @@ - `failed`, if at least one assertion has failed or if the test is todo and all assertions passed.

- `todo`, if the test is todo and at least one assertion failed.*
- **runtime**: `Number` - execution time in milliseconds.
- **errors**: `Array` - array containing all errors, i.e failed Assertions. It will contain at least one error for failed statuses and it will be empty for statuses other than failed.
- **assertions**: `Array` - array of Assertions containing all assertions passed and failed, for a skipped test there will be an empty array. Frameworks that don't track passed assertions can always provide an empty array for passed tests. In that case, for failed tests this should match the errors property.
- **runtime**: `Number` - execution time in milliseconds.
- **errors**: `Array` - array containing all errors, i.e failed Assertions. It will contain at least one error for failed statuses and it will be empty for statuses other than failed.
- **assertions**: `Array` - array of Assertions containing all assertions passed and failed, for a skipped test there will be an empty array. Frameworks that don't track passed assertions can always provide an empty array for passed tests. In that case, for failed tests this should match the errors property.

@@ -136,10 +134,10 @@ _*For more info about todo tests, please refer to the [QUnit documentation for todo tests](https://api.qunitjs.com/QUnit.todo/) and the [TAP 13 specification on the todo directive](https://testanything.org/tap-version-13-specification.html#directives)_.

- **Assertion**: `Object` - An object which contains information of a single assertion/expectation.
- **passed**: `Boolean` - `true` for a passed assertion, `failed` for a failed assertion.
- **actual**: `*` - the actual value passed to the assertion, should coincide with `expected` for passed assertions.
- **expected**: `*` - the expected value passed to the assertion, should coincide with `actual` for passed assertions.
- **message**: `String` - a description.
- **stack**: `String|undefined` - represents the stack trace for a failed assertion, for a `passed` one it is `undefined`.
- **todo**: `Boolean` - whether this assertion was part of a todo test
- **passed**: `Boolean` - `true` for a passed assertion, `failed` for a failed assertion.
- **actual**: `*` - the actual value passed to the assertion, should coincide with `expected` for passed assertions.
- **expected**: `*` - the expected value passed to the assertion, should coincide with `actual` for passed assertions.
- **message**: `String` - a description.
- **stack**: `String|undefined` - represents the stack trace for a failed assertion, for a `passed` one it is `undefined`.
- **todo**: `Boolean` - whether this assertion was part of a todo test
Additional properties (not defined here) can be added to the Assertion object.
Additional properties (not defined here) can be added to the Assertion object. If Assertion objects are included in the Test and Suite objects defined above, it is recommended to remove the `actual` and `expected` values after `TestEnd` occurs to avoid leaking memory.

@@ -157,23 +155,26 @@ ## Details

```js
// Attach one of the exiting adapters.
var runner = JsReporters.autoRegister();
// Attach one of the exiting adapters.
var runner = JsReporters.autoRegister();
// Listen to the same events for any testing framework.
runner.on('testEnd', function(test) {
console.log('Test %s has errors:', test.fullname.join(' '), test.errors);
});
// Listen to the same events for any testing framework.
runner.on('testEnd', function(test) {
console.log('Test %s has errors:', test.fullname.join(' '), test.errors);
});
runner.on('runEnd', function(globalSuite) {
var testCounts = globalSuite.testCounts;
runner.on('runEnd', function(globalSuite) {
var testCounts = globalSuite.testCounts;
console.log('Testsuite status: %s', globalSuite.status);
console.log('Testsuite status: %s', globalSuite.status);
console.log('Total %d tests: %d passed, %d failed, %d skipped', testCounts.total, testCounts.passed,
testCounts.failed, testCounts.skipped);
console.log('Total %d tests: %d passed, %d failed, %d skipped',
testCounts.total,
testCounts.passed,
testCounts.failed,
testCounts.skipped);
console.log('Total duration: %d', globalSuite.runtime);
});
console.log('Total duration: %d', globalSuite.runtime);
});
// Or use one of the built-in reporters.
JsReporters.TapReporter.init(runner);
// Or use one of the built-in reporters.
JsReporters.TapReporter.init(runner);
```

@@ -187,3 +188,3 @@

```
```js
JsReporters.autoRegister();

@@ -194,3 +195,3 @@ ```

- [browserstack-runner](https://github.com/browserstack/browserstack-runner/blob/master/lib/_patch/reporter.js)
- [browserstack-runner](https://github.com/browserstack/browserstack-runner/blob/master/lib/_patch/reporter.js)

@@ -213,15 +214,15 @@ ## Differences

- https://github.com/jquery/qunit/issues/531 (original discussion)
- https://github.com/visionmedia/mocha/issues/1326
- https://github.com/pivotal/jasmine/issues/659
- https://github.com/theintern/intern/issues/257
- https://github.com/busterjs/buster/issues/419
- https://github.com/caolan/nodeunit/issues/276
- https://github.com/flatiron/vows/issues/313
- https://github.com/qunitjs/qunit/issues/531 (original discussion)
- https://github.com/visionmedia/mocha/issues/1326
- https://github.com/pivotal/jasmine/issues/659
- https://github.com/theintern/intern/issues/257
- https://github.com/busterjs/buster/issues/419
- https://github.com/caolan/nodeunit/issues/276
- https://github.com/flatiron/vows/issues/313
### Consuming Services
- https://github.com/browserstack/browserstack-runner/issues/92
- https://github.com/axemclion/grunt-saucelabs/issues/164
- https://github.com/karma-runner/karma/issues/1183
- https://github.com/substack/testling/issues/93
- https://github.com/browserstack/browserstack-runner/issues/92
- https://github.com/axemclion/grunt-saucelabs/issues/164
- https://github.com/karma-runner/karma/issues/1183
- https://github.com/substack/testling/issues/93
# Release Process
1. Update `CHANGELOG.md` using `git changelog` from the [`git-extras`](https://github.com/tj/git-extras) package.
2. Commit changelog updates with message: `CHANGELOG: Update for x.x.x release`
1. Update `CHANGELOG.md` using `git changelog` from the [`git-extras`](https://github.com/tj/git-extras) package
2. Commit changelog updates with message: `Changelog: Update for x.x.x release`
3. Update `package.json` version and tag it using `npm version x.x.x -m "Release: vx.x.x"`
4. Push the two new commits to GitHub
4. Push the two new commits and tag to GitHub
5. Run `npm publish`
6. Publish a new [release on GitHub](https://github.com/js-reporters/js-reporters/releases) with the changelog update
That's all!

@@ -11,2 +11,22 @@ var TestEnd = require('../../dist/js-reporters.js').TestEnd

]),
actualUndefinedTest: new TestEnd('fail', undefined, [], 'failed', 0, [{
passed: false,
actual: undefined,
expected: 'expected'
}]),
actualFalsyTest: new TestEnd('fail', undefined, [], 'failed', 0, [{
passed: false,
actual: 0,
expected: 'expected'
}]),
expectedUndefinedTest: new TestEnd('fail', undefined, [], 'failed', 0, [{
passed: false,
actual: 'actual',
expected: undefined
}]),
expectedFalsyTest: new TestEnd('fail', undefined, [], 'failed', 0, [{
passed: false,
actual: 'actual',
expected: 0
}]),
skippedTest: new TestEnd('skip', undefined, [], 'skipped', 0, []),

@@ -13,0 +33,0 @@ todoTest: new TestEnd('todo', undefined, [], 'todo', 0, []),

@@ -79,4 +79,2 @@ /* eslint-env mocha */

console.warn(expected)
for (var i = 0; i < expected.length; i++) {

@@ -87,2 +85,34 @@ expect(spy).to.have.been.calledWith(expected[i])

it('should output actual value for failed assertions even it was undefined', sinon.test(function () {
var spy = this.stub(console, 'log')
emitter.emit('testEnd', data.actualUndefinedTest)
expect(spy).to.have.been.calledWith(' actual: undefined')
}))
it('should output actual value for failed assertions even it was falsy', sinon.test(function () {
var spy = this.stub(console, 'log')
emitter.emit('testEnd', data.actualFalsyTest)
expect(spy).to.have.been.calledWith(' actual: 0')
}))
it('should output expected value for failed assertions even it was undefined', sinon.test(function () {
var spy = this.stub(console, 'log')
emitter.emit('testEnd', data.expectedUndefinedTest)
expect(spy).to.have.been.calledWith(' expected: undefined')
}))
it('should output expected value for failed assertions even it was falsy', sinon.test(function () {
var spy = this.stub(console, 'log')
emitter.emit('testEnd', data.expectedFalsyTest)
expect(spy).to.have.been.calledWith(' expected: 0')
}))
it('should output the total number of tests', sinon.test(function () {

@@ -89,0 +119,0 @@ var spy = this.stub(console, 'log')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc