Skip to content

Commit

Permalink
setup jest
Browse files Browse the repository at this point in the history
  • Loading branch information
JVGS1111 committed Jul 18, 2024
1 parent 50a2d07 commit 33e17c1
Show file tree
Hide file tree
Showing 6 changed files with 6,461 additions and 2,143 deletions.
12 changes: 12 additions & 0 deletions __tests__/pages/home.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Home from '@/pages/home'
import { render, screen } from '@testing-library/react'

describe('Home', () => {
it('should be rendered correctly', () => {
render(<Home />)

const heading = screen.getByText('What do we have to do for today?')

expect(heading).toBeInTheDocument()
})
})
16 changes: 16 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const nextJest = require('next/jest')

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 customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testEnvironment: 'jsdom',
preset: 'ts-jest',
}

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom'
Loading

0 comments on commit 33e17c1

Please sign in to comment.