mirror of
https://github.com/andwati/blog-nest.git
synced 2026-12-04 09:48:48 +00:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { Config } from 'jest'
|
||||
import nextJest from 'next/jest.js'
|
||||
|
||||
const createJestConfig = nextJest({
|
||||
dir: './',
|
||||
})
|
||||
|
||||
const config: Config = {
|
||||
testEnvironment: 'jsdom',
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
|
||||
testRegex: '.*\\.spec\\.tsx?$',
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
},
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{ts,tsx}',
|
||||
'!src/**/*.spec.{ts,tsx}',
|
||||
'!src/**/layout.tsx',
|
||||
],
|
||||
coverageDirectory: 'coverage',
|
||||
}
|
||||
|
||||
export default createJestConfig(config)
|
||||
@@ -0,0 +1 @@
|
||||
import '@testing-library/jest-dom'
|
||||
@@ -9,7 +9,10 @@
|
||||
"lint": "biome check",
|
||||
"format": "biome format --write",
|
||||
"check-types": "tsc --noEmit",
|
||||
"clean": "rm -rf .next"
|
||||
"clean": "rm -rf .next",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "16.1.6",
|
||||
@@ -18,11 +21,17 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"babel-plugin-react-compiler": "1.0.0",
|
||||
"jest": "^30.2.0",
|
||||
"tailwindcss": "^4",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { render, screen } from '@testing-library/react'
|
||||
|
||||
import Home from './page'
|
||||
|
||||
jest.mock('next/image', () => ({
|
||||
__esModule: true,
|
||||
default: (props: React.ImgHTMLAttributes<HTMLImageElement>) => (
|
||||
// biome-ignore lint/a11y/useAltText: mock
|
||||
<img {...props} />
|
||||
),
|
||||
}))
|
||||
|
||||
describe('Home', () => {
|
||||
it('renders the Next.js logo', () => {
|
||||
render(<Home />)
|
||||
const logo = screen.getByAltText('Next.js logo')
|
||||
expect(logo).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user