Skip to content

Commit 6188026

Browse files
Add comprehensive unit tests with Jest and React Testing Library
Co-authored-by: ColtonRandall <65145150+ColtonRandall@users.noreply.github.com>
1 parent 5a9b657 commit 6188026

7 files changed

Lines changed: 8058 additions & 2809 deletions

File tree

jest.config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { Config } from 'jest'
2+
import nextJest from 'next/jest'
3+
4+
const createJestConfig = nextJest({
5+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
6+
dir: './',
7+
})
8+
9+
// Add any custom config to be passed to Jest
10+
const config: Config = {
11+
coverageProvider: 'v8',
12+
testEnvironment: 'jsdom',
13+
// Add more setup options before each test is run
14+
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
15+
moduleNameMapper: {
16+
'^@/(.*)$': '<rootDir>/src/$1',
17+
},
18+
testMatch: [
19+
'**/__tests__/**/*.test.[jt]s?(x)',
20+
'**/?(*.)+(spec|test).[jt]s?(x)'
21+
],
22+
}
23+
24+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
25+
export default createJestConfig(config)

jest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom'

0 commit comments

Comments
 (0)