Skip to content

Commit 37dba4a

Browse files
committed
chore: setup jest
1 parent 4f8dec9 commit 37dba4a

File tree

5 files changed

+89
-20
lines changed

5 files changed

+89
-20
lines changed

__test__/config/jest-setup.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom';

jest.config.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"roots": ["<rootDir>/__test__"],
3+
"collectCoverageFrom": [
4+
"<rootDir>/src/**/*.{ts,tsx}",
5+
"!<rootDir>/src/**/index.ts",
6+
"!<rootDir>/src/main/**",
7+
"!**/*.d.ts"
8+
],
9+
"testPathIgnorePatterns": ["<rootDir>/__test__/integration"],
10+
"coverageDirectory": "coverage",
11+
"setupFilesAfterEnv": ["<rootDir>/__test__/config/jest-setup.ts"],
12+
"testEnvironment": "jsdom",
13+
"transform": {
14+
".+\\.ts(x?)$": "ts-jest"
15+
},
16+
"moduleNameMapper": {
17+
"\\.scss$": "identity-obj-proxy",
18+
"@/test/(.*)": "<rootDir>/__test__/$1",
19+
"@/(.*)": "<rootDir>/src/$1"
20+
}
21+
}

package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
"scripts": {
1010
"prepare": "husky install",
1111
"start": "react-scripts start",
12-
"build": "react-scripts build"
12+
"build": "react-scripts build",
13+
"test": "jest --passWithNoTests --no-cache --runInBand",
14+
"test:watch": "yarn test --watch",
15+
"test:staged": "yarn test --findRelatedTests",
16+
"test:ci": "yarn test --coverage"
1317
},
1418
"dependencies": {
1519
"react": "^17.0.2",
@@ -37,9 +41,11 @@
3741
"eslint-plugin-react-hooks": "^4.2.0",
3842
"git-commit-msg-linter": "^3.1.0",
3943
"husky": "^6.0.0",
44+
"identity-obj-proxy": "^3.0.0",
4045
"lint-staged": "^10.5.4",
4146
"prettier": "^2.2.1",
4247
"react-scripts": "4.0.3",
48+
"ts-jest": "^26.5.4",
4349
"typescript": "^4.1.2",
4450
"web-vitals": "^1.0.1"
4551
},

tsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"noEmit": true,
17-
"jsx": "react-jsx"
17+
"jsx": "react-jsx",
18+
"rootDirs": ["src", "__test__"]
1819
},
19-
"include": ["src"]
20+
"include": ["src", "__test__"]
2021
}

yarn.lock

+57-17
Original file line numberDiff line numberDiff line change
@@ -3023,14 +3023,21 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4
30233023
escalade "^3.1.1"
30243024
node-releases "^1.1.70"
30253025

3026+
3027+
version "0.2.6"
3028+
resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8"
3029+
integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==
3030+
dependencies:
3031+
fast-json-stable-stringify "2.x"
3032+
30263033
30273034
version "2.1.1"
30283035
resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05"
30293036
integrity sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==
30303037
dependencies:
30313038
node-int64 "^0.4.0"
30323039

3033-
buffer-from@^1.0.0:
3040+
buffer-from@1.x, buffer-from@^1.0.0:
30343041
version "1.1.1"
30353042
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
30363043
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
@@ -5122,7 +5129,7 @@ fast-glob@^3.1.1:
51225129
micromatch "^4.0.2"
51235130
picomatch "^2.2.1"
51245131

5125-
fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0:
5132+
fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0:
51265133
version "2.1.0"
51275134
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
51285135
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
@@ -5902,7 +5909,7 @@ icss-utils@^4.0.0, icss-utils@^4.1.1:
59025909
dependencies:
59035910
postcss "^7.0.14"
59045911

5905-
5912+
[email protected], identity-obj-proxy@^3.0.0:
59065913
version "3.0.0"
59075914
resolved "https://registry.yarnpkg.com/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14"
59085915
integrity sha1-lNK9qWCERT7zb7xarsN+D3nx/BQ=
@@ -6823,7 +6830,7 @@ jest-snapshot@^26.6.0, jest-snapshot@^26.6.2:
68236830
pretty-format "^26.6.2"
68246831
semver "^7.3.2"
68256832

6826-
jest-util@^26.6.0, jest-util@^26.6.2:
6833+
jest-util@^26.1.0, jest-util@^26.6.0, jest-util@^26.6.2:
68276834
version "26.6.2"
68286835
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1"
68296836
integrity sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==
@@ -6999,20 +7006,20 @@ json3@^3.3.3:
69997006
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81"
70007007
integrity sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==
70017008

7009+
[email protected], json5@^2.1.2:
7010+
version "2.2.0"
7011+
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3"
7012+
integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==
7013+
dependencies:
7014+
minimist "^1.2.5"
7015+
70027016
json5@^1.0.1:
70037017
version "1.0.1"
70047018
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
70057019
integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==
70067020
dependencies:
70077021
minimist "^1.2.0"
70087022

7009-
json5@^2.1.2:
7010-
version "2.2.0"
7011-
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3"
7012-
integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==
7013-
dependencies:
7014-
minimist "^1.2.5"
7015-
70167023
jsonfile@^4.0.0:
70177024
version "4.0.0"
70187025
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
@@ -7273,7 +7280,7 @@ lodash.uniq@^4.5.0:
72737280
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
72747281
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
72757282

7276-
"lodash@>=3.5 <5", lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.5:
7283+
[email protected], "lodash@>=3.5 <5", lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.5:
72777284
version "4.17.21"
72787285
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
72797286
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@@ -7356,6 +7363,11 @@ make-dir@^3.0.0, make-dir@^3.0.2:
73567363
dependencies:
73577364
semver "^6.0.0"
73587365

7366+
7367+
version "1.3.6"
7368+
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
7369+
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
7370+
73597371
73607372
version "1.0.11"
73617373
resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c"
@@ -7599,18 +7611,18 @@ mixin-deep@^1.2.0:
75997611
for-in "^1.0.2"
76007612
is-extendable "^1.0.1"
76017613

7614+
[email protected], mkdirp@^1.0.3, mkdirp@^1.0.4:
7615+
version "1.0.4"
7616+
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
7617+
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
7618+
76027619
mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5, mkdirp@~0.5.1:
76037620
version "0.5.5"
76047621
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
76057622
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
76067623
dependencies:
76077624
minimist "^1.2.5"
76087625

7609-
mkdirp@^1.0.3, mkdirp@^1.0.4:
7610-
version "1.0.4"
7611-
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
7612-
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
7613-
76147626
move-concurrently@^1.0.1:
76157627
version "1.0.1"
76167628
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
@@ -10062,6 +10074,13 @@ [email protected]:
1006210074
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
1006310075
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
1006410076

10077+
10078+
version "7.3.5"
10079+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
10080+
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
10081+
dependencies:
10082+
lru-cache "^6.0.0"
10083+
1006510084
semver@^6.0.0, semver@^6.3.0:
1006610085
version "6.3.0"
1006710086
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
@@ -10979,6 +10998,22 @@ tryer@^1.0.1:
1097910998
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
1098010999
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
1098111000

11001+
ts-jest@^26.5.4:
11002+
version "26.5.4"
11003+
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.4.tgz#207f4c114812a9c6d5746dd4d1cdf899eafc9686"
11004+
integrity sha512-I5Qsddo+VTm94SukBJ4cPimOoFZsYTeElR2xy6H2TOVs+NsvgYglW8KuQgKoApOKuaU/Ix/vrF9ebFZlb5D2Pg==
11005+
dependencies:
11006+
bs-logger "0.x"
11007+
buffer-from "1.x"
11008+
fast-json-stable-stringify "2.x"
11009+
jest-util "^26.1.0"
11010+
json5 "2.x"
11011+
lodash "4.x"
11012+
make-error "1.x"
11013+
mkdirp "1.x"
11014+
semver "7.x"
11015+
yargs-parser "20.x"
11016+
1098211017
[email protected], ts-pnp@^1.1.6:
1098311018
version "1.2.0"
1098411019
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
@@ -11845,6 +11880,11 @@ yaml@^1.10.0, yaml@^1.7.2:
1184511880
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
1184611881
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==
1184711882

11883+
11884+
version "20.2.7"
11885+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a"
11886+
integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==
11887+
1184811888
yargs-parser@^13.1.2:
1184911889
version "13.1.2"
1185011890
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38"

0 commit comments

Comments
 (0)