Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoqoi committed Jul 24, 2021
1 parent 71974bc commit d21e559
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
11 changes: 7 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
testEnvironment: 'jsdom',

// The root of your source code, typically /src
// `<rootDir>` is a token Jest substitutes
roots: ['<rootDir>/src'],
Expand All @@ -12,16 +14,17 @@ module.exports = {
// Runs special logic, such as cleaning up components
// when using React Testing Library and adds special
// extended assertions to Jest
setupFilesAfterEnv: [
'@testing-library/react/cleanup-after-each',
'@testing-library/jest-dom/extend-expect',
],
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],

// Test spec file resolution pattern
// Matches parent folder `__tests__` and filename
// should contain `test` or `spec`.
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',

moduleNameMapper: {
'@/(.*)$': '<rootDir>/src/$1',
},

// Module file extensions for importing
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@types/chroma-js": "^2.1.3",
"@types/jest": "^26.0.23",
"@types/jest": "^26.0.24",
"@types/react": "^17.0.13",
"@types/react-dom": "^17.0.8",
"@typescript-eslint/eslint-plugin": "^4.21.0",
Expand All @@ -60,7 +60,7 @@
"prettier": "^2.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"ts-jest": "^27.0.3",
"ts-jest": "^27.0.4",
"tsconfig-paths": "^3.10.1",
"tsconfig-paths-webpack-plugin": "^3.5.1",
"tscpaths": "^0.0.9",
Expand Down
8 changes: 8 additions & 0 deletions src/utils/CCProvider/CCProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render } from '@testing-library/react'
import { CCProvider } from '@/utils/CCProvider/CCProvider'

describe('CCProvider', () => {
it('should render', () => {
render(<CCProvider />)
})
})
10 changes: 10 additions & 0 deletions src/views/Category/Category.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { render } from '@testing-library/react'
import { Category } from '@/views/Category/Category'

describe('Category', () => {
it('should render with title', () => {
const { getByText } = render(<Category title="Test Title" />)

expect(getByText('Test Title')).toBeInTheDocument()
})
})
18 changes: 13 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4053,14 +4053,22 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@*", "@types/jest@^26.0.23":
"@types/jest@*":
version "26.0.23"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.23.tgz#a1b7eab3c503b80451d019efb588ec63522ee4e7"
integrity sha512-ZHLmWMJ9jJ9PTiT58juykZpL7KjwJywFN3Rr2pTSkyQfydf/rk22yS7W8p5DaVUMQ2BQC7oYiU3FjbTM/mYrOA==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"

"@types/jest@^26.0.24":
version "26.0.24"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.24.tgz#943d11976b16739185913a1936e0de0c4a7d595a"
integrity sha512-E/X5Vib8BWqZNRlDxj9vYXhsDwPYbPINqKF9BsnSoon4RQ0D9moEuLD8txgyypFLH7J4+Lho9Nr/c8H0Fi+17w==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"

"@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6", "@types/json-schema@^7.0.7":
version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
Expand Down Expand Up @@ -14535,10 +14543,10 @@ ts-essentials@^2.0.3:
resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-2.0.12.tgz#c9303f3d74f75fa7528c3d49b80e089ab09d8745"
integrity sha512-3IVX4nI6B5cc31/GFFE+i8ey/N2eA0CZDbo6n0yrz0zDX8ZJ8djmU1p+XRz7G3is0F3bB3pu2pAroFdAWQKU3w==

ts-jest@^27.0.3:
version "27.0.3"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.3.tgz#808492f022296cde19390bb6ad627c8126bf93f8"
integrity sha512-U5rdMjnYam9Ucw+h0QvtNDbc5+88nxt7tbIvqaZUhFrfG4+SkWhMXjejCLVGcpILTPuV+H3W/GZDZrnZFpPeXw==
ts-jest@^27.0.4:
version "27.0.4"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.4.tgz#df49683535831560ccb58f94c023d831b1b80df0"
integrity sha512-c4E1ECy9Xz2WGfTMyHbSaArlIva7Wi2p43QOMmCqjSSjHP06KXv+aT+eSY+yZMuqsMi3k7pyGsGj2q5oSl5WfQ==
dependencies:
bs-logger "0.x"
buffer-from "1.x"
Expand Down

0 comments on commit d21e559

Please sign in to comment.