Skip to content

Commit

Permalink
sample jest unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
karkir0003 committed Feb 23, 2024
1 parent ee9ec1a commit fd3ed12
Show file tree
Hide file tree
Showing 5 changed files with 2,287 additions and 115 deletions.
6 changes: 0 additions & 6 deletions frontend/jest.config.js

This file was deleted.

18 changes: 18 additions & 0 deletions frontend/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Config } from 'jest'
import nextJest from 'next/jest.js'

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})

// Add any custom config to be passed to Jest
const config: Config = {
coverageProvider: 'v8',
testEnvironment: 'jsdom',
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
}

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config)
9 changes: 8 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"lint": "next lint",
"start": "next dev"
"start": "next dev",
"test": "jest",
"test:watch": "jest --watch"
},
"keywords": [],
"author": "",
Expand Down Expand Up @@ -56,13 +58,18 @@
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.0.1",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"depcheck": "^1.4.7",
"eslint": "^8.52.0",
"eslint-plugin-react": "^7.33.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "3.2.2",
"ts-node": "^10.9.2",
"typescript": "^5.2.2"
}
}
Loading

0 comments on commit fd3ed12

Please sign in to comment.