Skip to content

Commit a915814

Browse files
author
Marek Rozmus
committed
Add tests and fix found issues
1 parent 435ee56 commit a915814

12 files changed

+6466
-2152
lines changed

.babelrc

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

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"env": {
33
"browser": true,
4-
"node": true
4+
"node": true,
5+
"jest": true
56
},
67
"extends": [
78
"eslint:recommended",

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.stylelintcache
33
node_modules/
44
dist
5+
coverage

babel.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const presets = [
2+
[
3+
'@babel/preset-env',
4+
{
5+
targets: {
6+
browsers: [
7+
'>0.25%',
8+
'not ie 11',
9+
'not op_mini all',
10+
'safari >= 11',
11+
'not safari 5.1'
12+
],
13+
node: 'current'
14+
},
15+
modules: false
16+
}
17+
],
18+
'@babel/preset-react'
19+
];
20+
21+
const plugins = ['@babel/plugin-proposal-class-properties'];
22+
23+
module.exports = function(api) {
24+
api.cache.invalidate(() => process.env.NODE_ENV);
25+
const isTest = api.env('test');
26+
27+
if (isTest) {
28+
plugins.push('@babel/plugin-transform-modules-commonjs');
29+
}
30+
31+
return {
32+
presets,
33+
plugins
34+
};
35+
};

jest.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// For a detailed explanation regarding each configuration property, visit:
2+
// https://jestjs.io/docs/en/configuration.html
3+
4+
module.exports = {
5+
// Automatically clear mock calls and instances between every test
6+
clearMocks: true,
7+
8+
// Indicates whether the coverage information should be collected while executing the test
9+
collectCoverage: true,
10+
11+
// An array of glob patterns indicating a set of files for which coverage information should be collected
12+
collectCoverageFrom: ['src/**/*.js', '!src/__tests__/*.*'],
13+
14+
// The directory where Jest should output its coverage files
15+
coverageDirectory: 'coverage',
16+
17+
// A map from regular expressions to module names that allow to stub out resources with a single module
18+
moduleNameMapper: {
19+
'\\.css$': 'identity-obj-proxy'
20+
},
21+
22+
// The glob patterns Jest uses to detect test files
23+
testMatch: ['**/__tests__/**/*.test.js'],
24+
25+
// A map from regular expressions to paths to transformers
26+
transform: {
27+
'\\.js$': ['babel-jest'],
28+
'.+\\.(css)$': 'jest-transform-css'
29+
}
30+
};

0 commit comments

Comments
 (0)