Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit b5e57fd

Browse files
authored
test: Setting up test framework for JS unit tests (#1)
1 parent 2697cb0 commit b5e57fd

File tree

8 files changed

+9627
-0
lines changed

8 files changed

+9627
-0
lines changed

.eslintrc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: google
2+
parser: babel-eslint
3+
rules:
4+
strict: 0
5+
require-jsdoc: off
6+
valid-jsdoc: off
7+
switch-colon-spacing: 0

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage
2+
node_modules
3+
.DS_Store

karma.conf.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Karma configuration
2+
// Generated on Tue Mar 06 2018 14:20:28 GMT-0800 (PST)
3+
const path = require('path');
4+
5+
module.exports = function(config) {
6+
config.set({
7+
8+
// base path that will be used to resolve all patterns (eg. files, exclude)
9+
basePath: '',
10+
11+
12+
// frameworks to use
13+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
14+
frameworks: ['mocha'],
15+
16+
17+
// list of files / patterns to load in the browser
18+
files: [
19+
'test/unit/index.js'
20+
],
21+
22+
23+
// list of files / patterns to exclude
24+
exclude: [
25+
],
26+
27+
28+
// preprocess matching files before serving them to the browser
29+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
30+
preprocessors: {
31+
'test/unit/index.js': ['webpack']
32+
},
33+
34+
webpack: {
35+
devtool: 'inline-source-map',
36+
module: {
37+
loaders: [
38+
{ test: /\.js?$/, loader: 'babel-loader' }
39+
],
40+
rules: [
41+
// instrument only testing sources with Istanbul
42+
{
43+
test: /\.js$/,
44+
use: {
45+
loader: 'istanbul-instrumenter-loader',
46+
options: {esModules: true}
47+
},
48+
include: path.resolve('packages/'),
49+
exclude: [
50+
/node_modules/
51+
],
52+
enforce: 'post'
53+
}
54+
]
55+
}
56+
},
57+
58+
client: {
59+
mocha: {
60+
reporter: 'html',
61+
ui: 'qunit',
62+
},
63+
},
64+
65+
// test results reporter to use
66+
// possible values: 'dots', 'progress'
67+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
68+
reporters: ['progress', 'coverage'],
69+
70+
coverageReporter: {
71+
dir: 'coverage',
72+
reporters: [
73+
{type: 'lcovonly', subdir: '.'},
74+
{type: 'json', subdir: '.', file: 'coverage.json'},
75+
{type: 'html'},
76+
],
77+
},
78+
79+
80+
// web server port
81+
port: 9876,
82+
83+
84+
// enable / disable colors in the output (reporters and logs)
85+
colors: true,
86+
87+
88+
// level of logging
89+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
90+
logLevel: config.LOG_INFO,
91+
92+
93+
// enable / disable watching file and executing tests whenever any file changes
94+
autoWatch: false,
95+
96+
97+
// start these browsers
98+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
99+
browsers: ['Chrome'],
100+
101+
102+
// Continuous Integration mode
103+
// if true, Karma captures browsers, runs the tests and exits
104+
singleRun: false,
105+
106+
// Concurrency level
107+
// how many browser should be started simultaneous
108+
concurrency: Infinity,
109+
})
110+
}

0 commit comments

Comments
 (0)