Skip to content

Commit 4fe42ce

Browse files
committed
Run test suite in Node.js. Switch to using c8 for test coverage instead of istanbul; it seems to be the current recommended coverage package.
In order to run in Node, I had to add "type": "module" to the package.json. This had some knock-on effects, like I had to make import statements in the tests ECMAScript-compliant by adding file extensions. I then also had to rename config files that use CommonJS-style require() instead of import to the .cjs extension.
1 parent 998d95d commit 4fe42ce

17 files changed

+213
-148
lines changed

.c8rc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"include": ["src/"],
3+
"reporter": ["html"],
4+
"report-dir": "coverage"
5+
}

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
'parser': 'babel-eslint',
2+
'parser': '@babel/eslint-parser',
33
'env': {
44
'browser': true,
55
'es6': true,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
2-
const webpackConfig = require('../webpack');
2+
const webpackConfig = require('../webpack/index.cjs');
33

44
/* eslint no-process-env:0 */
55
process.env.CHROME_BIN = require('puppeteer').executablePath();
@@ -12,16 +12,13 @@ delete webpackConfig.output.library;
1212
webpackConfig.module.rules.push({
1313
test: /\.js$/,
1414
include: path.resolve('./src/'),
15-
loader: 'babel-loader',
16-
options: {
17-
plugins: ['babel-plugin-istanbul']
18-
}
15+
loader: 'babel-loader'
1916
});
2017

2118
module.exports = {
2219
basePath: '../../',
2320
frameworks: ['mocha'],
24-
reporters: ['progress', 'coverage'],
21+
reporters: ['progress'],
2522
files: [
2623
'test/**/*_test.js'
2724
],
@@ -30,8 +27,7 @@ module.exports = {
3027
'karma-webpack',
3128
'karma-mocha',
3229
'karma-chrome-launcher',
33-
'karma-firefox-launcher',
34-
'karma-coverage'
30+
'karma-firefox-launcher'
3531
],
3632

3733
preprocessors: {
@@ -48,15 +44,5 @@ module.exports = {
4844
timings: false,
4945
errorDetails: true
5046
}
51-
},
52-
53-
coverageReporter: {
54-
dir: './coverage',
55-
reporters: [
56-
{type: 'html', subdir: 'html'},
57-
{type: 'lcov', subdir: '.'},
58-
{type: 'text', subdir: '.', file: 'text.txt'},
59-
{type: 'text-summary', subdir: '.', file: 'text-summary.txt'}
60-
]
6147
}
6248
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const extendConfiguration = require('./karma-extend.js');
1+
const extendConfiguration = require('./karma-extend.cjs');
22

33
module.exports = function (config) {
44
'use strict';

config/karma/karma-coverage.js

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

config/karma/karma-coveralls.js

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const baseConfig = require('./karma-base.js');
1+
const baseConfig = require('./karma-base.cjs');
22

33
module.exports = function (extendedConfig) {
44
'use strict';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const extendConfiguration = require('./karma-extend.js');
1+
const extendConfiguration = require('./karma-extend.cjs');
22

33
module.exports = function (config) {
44
'use strict';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const extendConfiguration = require('./karma-extend.js');
1+
const extendConfiguration = require('./karma-extend.cjs');
22

33
module.exports = function (config) {
44
'use strict';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
22
const env = process.env.ENV || 'dev';
3-
const config = require(`./webpack-${env}`);
3+
const config = require(`./webpack-${env}.cjs`);
44

55
module.exports = config;

0 commit comments

Comments
 (0)