Skip to content

Commit 5246726

Browse files
committed
Move jest and eslint configs to their own files.
Fix the CompletedFilesCounter test
1 parent 65bbfcf commit 5246726

File tree

4 files changed

+47
-39
lines changed

4 files changed

+47
-39
lines changed

.eslintrc.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
extends: ['react-app'],
5+
plugins: ['prettier', '@emotion'],
6+
rules: {
7+
'prettier/prettier': 'error',
8+
'jsx-a11y/accessible-emoji': 'off',
9+
'import/no-anonymous-default-export': 'off',
10+
'react-hooks/exhaustive-deps': 'off',
11+
},
12+
overrides: [
13+
{
14+
files: ['src/__tests__/**/*'],
15+
env: {
16+
jest: true,
17+
},
18+
},
19+
],
20+
}

jest.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
transform: {
5+
'^.+\\.(js|jsx|ts|tsx)?$': 'ts-jest',
6+
},
7+
transformIgnorePatterns: ['<rootDir>/node_modules/'],
8+
testMatch: ['<rootDir>>/__tests__/**/*.spec.(js|jsx|ts|tsx)'],
9+
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
10+
}

package.json

+2-36
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@jest/globals": "^29.7.0",
4242
"@testing-library/react": "^14.0.0",
4343
"@types/jest": "^29.5.12",
44+
"@types/jest-image-snapshot": "^6.4.0",
4445
"@types/markdown-to-jsx": "^7.0.1",
4546
"@types/node": "^20.11.16",
4647
"@types/react": "18.2.0",
@@ -55,7 +56,7 @@
5556
"eslint-plugin-prettier": "^4.2.1",
5657
"gh-pages": "5.0.0",
5758
"husky": "8.0.3",
58-
"jest-image-snapshot": "6.1.0",
59+
"jest-image-snapshot": "6.4.0",
5960
"prettier": "2.8.4",
6061
"pretty-quick": "3.1.3",
6162
"puppeteer": "10.0.0",
@@ -75,45 +76,10 @@
7576
"last 1 safari version"
7677
]
7778
},
78-
"eslintConfig": {
79-
"parser": "@typescript-eslint/parser",
80-
"extends": [
81-
"react-app"
82-
],
83-
"plugins": [
84-
"prettier",
85-
"@emotion"
86-
],
87-
"rules": {
88-
"prettier/prettier": "error",
89-
"jsx-a11y/accessible-emoji": "off",
90-
"import/no-anonymous-default-export": "off",
91-
"react-hooks/exhaustive-deps": "off"
92-
},
93-
"overrides": [
94-
{
95-
"files": [
96-
"src/__tests__/**/*"
97-
],
98-
"env": {
99-
"jest": true
100-
}
101-
}
102-
]
103-
},
10479
"husky": {
10580
"hooks": {
10681
"pre-commit": "pretty-quick --staged --pattern \"src/**/*.*(js|jsx|ts|tsx)\"",
10782
"pre-push": "yarn run lint"
10883
}
109-
},
110-
"jest": {
111-
"preset": "ts-jest",
112-
"testMatch": [
113-
"**/__tests__/**/*.spec.(js|jsx|ts|tsx)"
114-
],
115-
"setupFilesAfterEnv": [
116-
"<rootDir>/jest.setup.js"
117-
]
11884
}
11985
}

src/__tests__/components/common/CompletedFilesCounter.spec.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
import React from 'react'
22
import { render } from '@testing-library/react'
33
import CompletedFilesCounter from '../../../components/common/CompletedFilesCounter'
4+
import { lightTheme } from '../../../theme'
45

56
it('renders without crashing', () => {
6-
const { container } = render(<CompletedFilesCounter />)
7+
const { container } = render(
8+
<CompletedFilesCounter
9+
completed={10}
10+
total={11}
11+
popoverContent=""
12+
popoverCursorType="pointer"
13+
theme={lightTheme}
14+
/>
15+
)
716

817
expect(container).toMatchInlineSnapshot(`
918
<div>
1019
<div
11-
class="css-11o7zpc"
20+
class="css-cs3rl"
1221
>
1322
<span>
1423
<span
1524
class="completedAmount"
16-
/>
25+
>
26+
10
27+
</span>
1728
1829
/
30+
11
1931
</span>
2032
<div
2133
style="position: relative;"

0 commit comments

Comments
 (0)