Skip to content

Commit c2f6042

Browse files
committed
Release: Bring back Rollup, Add coverage, Add browser test
Follows-up 3708273. Now that I've had a while to take inventory, I think we can bring this back to make distribution and re-use a bit easier for things like browserstack-runner. Highlights: * Switch from 'chalk' to 'kleur'. Kleur is a a dependency-free alternative that is safe to run in a browser environment without needing to do anything extra to emulate Node etc. Downstream browserstack-runner was having to mock the Node 'process' global previously because of this. There are ways around that, but it's naturally simplest to just not have any code that is just naturally agnostic of Node vs browser. Ref browserstack/browserstack-runner#179. * Use Karma to run the unit tests in the browser. * Use NYC to generate a code coverage report over the unit and integration tests.
1 parent 1455774 commit c2f6042

16 files changed

+4017
-112
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock.json binary

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/.nyc_output
2+
/coverage
3+
/dist
14
/node_modules
25
/log
36
/*.log

.npmignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ node_js:
33
- '10' # LTS
44
- '12' # LTS
55
- '14' # Current
6-
script:
7-
- "npm test"
6+
jobs:
7+
include:
8+
- name: Code coverage
9+
os: linux
10+
node_js: "14"
11+
script: npm run coveralls

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2014-2020 JS Reporters <https://github.com/js-reporters/>
1+
Copyright JS Reporters <https://github.com/js-reporters/>
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# js-reporters
22

3-
[![Build Status](https://travis-ci.org/js-reporters/js-reporters.svg?branch=master)](https://travis-ci.org/js-reporters/js-reporters)
43
[![Chat on Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/js-reporters/js-reporters)
4+
[![Build Status](https://travis-ci.org/js-reporters/js-reporters.svg?branch=master)](https://travis-ci.org/js-reporters/js-reporters)
5+
[![Coverage Status](https://coveralls.io/repos/github/js-reporters/js-reporters/badge.svg?branch=master)](https://coveralls.io/github/js-reporters/js-reporters?branch=master)
56
[![npm](https://img.shields.io/npm/dm/js-reporters.svg)](https://www.npmjs.com/package/js-reporters)
67
[![npm](https://img.shields.io/npm/v/js-reporters.svg)](https://www.npmjs.com/package/js-reporters)
7-
[![npm](https://img.shields.io/npm/l/js-reporters.svg?maxAge=2592000)](https://www.npmjs.com/package/js-reporters)
88

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

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const EventEmitter = require('events');
12
const QUnitAdapter = require('./lib/adapters/QUnitAdapter.js');
23
const JasmineAdapter = require('./lib/adapters/JasmineAdapter.js');
34
const MochaAdapter = require('./lib/adapters/MochaAdapter.js');
@@ -23,6 +24,7 @@ module.exports = {
2324
TestEnd,
2425
SuiteStart,
2526
SuiteEnd,
27+
EventEmitter,
2628
createSuiteStart,
2729
createTestStart,
2830
createTestEnd,

karma.conf.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
module.exports = function (config) {
2+
const { nodeResolve } = require('@rollup/plugin-node-resolve');
3+
const commonjs = require('@rollup/plugin-commonjs');
4+
5+
config.set({
6+
files: [
7+
'node_modules/sinon/pkg/sinon.js',
8+
'test/unit/tap-reporter.js',
9+
'test/unit/helpers.js'
10+
],
11+
preprocessors: {
12+
'test/unit/**.js': ['rollup']
13+
},
14+
rollupPreprocessor: {
15+
external: ['sinon'],
16+
output: {
17+
globals: {
18+
sinon: 'sinon'
19+
},
20+
format: 'iife',
21+
name: 'JsReporters_Test',
22+
sourcemap: true
23+
},
24+
plugins: [
25+
// For 'events' and 'kleur'
26+
nodeResolve({
27+
preferBuiltins: false
28+
}),
29+
commonjs({
30+
// This makes require() work like in Node.js,
31+
// instead of wrapped in a {default:…} object.
32+
requireReturnsDefault: 'auto'
33+
})
34+
]
35+
},
36+
frameworks: ['qunit'],
37+
browsers: ['FirefoxHeadless', 'ChromeHeadless'],
38+
singleRun: true,
39+
autoWatch: false
40+
});
41+
};

lib/reporters/TapReporter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const chalk = require('chalk');
1+
const kleur = require('kleur');
22

33
const hasOwn = Object.hasOwnProperty;
44

@@ -140,22 +140,22 @@ module.exports = class TapReporter {
140140
if (test.status === 'passed') {
141141
console.log(`ok ${this.testCount} ${test.fullName.join(' > ')}`);
142142
} else if (test.status === 'skipped') {
143-
console.log(chalk.yellow(`ok ${this.testCount} # SKIP ${test.fullName.join(' > ')}`));
143+
console.log(kleur.yellow(`ok ${this.testCount} # SKIP ${test.fullName.join(' > ')}`));
144144
} else if (test.status === 'todo') {
145-
console.log(chalk.cyan(`not ok ${this.testCount} # TODO ${test.fullName.join(' > ')}`));
145+
console.log(kleur.cyan(`not ok ${this.testCount} # TODO ${test.fullName.join(' > ')}`));
146146
test.errors.forEach((error) => this.logError(error, 'todo'));
147147
} else {
148-
console.log(chalk.red(`not ok ${this.testCount} ${test.fullName.join(' > ')}`));
148+
console.log(kleur.red(`not ok ${this.testCount} ${test.fullName.join(' > ')}`));
149149
test.errors.forEach((error) => this.logError(error));
150150
}
151151
}
152152

153153
onRunEnd (globalSuite) {
154154
console.log(`1..${globalSuite.testCounts.total}`);
155155
console.log(`# pass ${globalSuite.testCounts.passed}`);
156-
console.log(chalk.yellow(`# skip ${globalSuite.testCounts.skipped}`));
157-
console.log(chalk.cyan(`# todo ${globalSuite.testCounts.todo}`));
158-
console.log(chalk.red(`# fail ${globalSuite.testCounts.failed}`));
156+
console.log(kleur.yellow(`# skip ${globalSuite.testCounts.skipped}`));
157+
console.log(kleur.cyan(`# todo ${globalSuite.testCounts.todo}`));
158+
console.log(kleur.red(`# fail ${globalSuite.testCounts.failed}`));
159159
}
160160

161161
logError (error, severity) {

0 commit comments

Comments
 (0)