Skip to content

Commit 3a3570a

Browse files
authored
Merge pull request #3 from Quilljou/master
chore: ✨Make jest + enzyme work
2 parents 1ce3b04 + dc1e72d commit 3a3570a

File tree

11 files changed

+2623
-128
lines changed

11 files changed

+2623
-128
lines changed

.eslintrc

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{
22
"parser": "@typescript-eslint/parser",
3-
"extends": ["airbnb-typescript", "plugin:@typescript-eslint/recommended", "prettier", "prettier/react", "prettier/@typescript-eslint"],
4-
"plugins": ["@typescript-eslint"],
3+
"env": {
4+
"jest": true,
5+
"node": true
6+
},
7+
"extends": ["airbnb-typescript", "plugin:@typescript-eslint/recommended", "plugin:react/recommended", "prettier", "prettier/react", "prettier/@typescript-eslint"],
8+
"plugins": ["@typescript-eslint", "react"],
59
"parserOptions": {
610
"project": "./tsconfig.json",
711
"ecmaFeatures": {
812
"jsx": true
913
}
1014
},
1115
"rules": {
12-
"react/prefer-stateless-function": 0
16+
"react/prefer-stateless-function": 0,
17+
"react/button-has-type": 0,
18+
"import/no-extraneous-dependencies": 0
1319
}
1420
}

.babelrc renamed to babel.config.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
const basic = {
22
"presets": [
33
["@babel/preset-env", {
44
"debug": true,
@@ -13,3 +13,10 @@
1313
["@babel/plugin-proposal-class-properties"]
1414
]
1515
}
16+
17+
module.exports = function babel(api) {
18+
if(api.env('test')) {
19+
basic.presets[0][1].modules = 'cjs'
20+
}
21+
return basic;
22+
}

jest.config.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
module.exports = {
3+
setupFiles: ["<rootDir>/scripts/jest/setupTests.js"],
4+
"verbose": true,
5+
snapshotSerializers: ["enzyme-to-json/serializer"],
6+
moduleNameMapper: {
7+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/scripts/jest/__mocks__/fileMock.js",
8+
"\\.(css|styl)$": "<rootDir>/scripts/jest/__mocks__/styleMock.js"
9+
},
10+
moduleFileExtensions: [
11+
'ts',
12+
'tsx',
13+
'js',
14+
'jsx',
15+
'json',
16+
'node',
17+
],
18+
}

0 commit comments

Comments
 (0)