Skip to content

Instantly share code, notes, and snippets.

@shawn-sandy
Last active April 9, 2023 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawn-sandy/0d22967acffb39d8637a91a7fd9d15f6 to your computer and use it in GitHub Desktop.
Save shawn-sandy/0d22967acffb39d8637a91a7fd9d15f6 to your computer and use it in GitHub Desktop.
nextra
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: 'jest-environment-jsdom',
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
// Optional: configure or set up a testing framework before each test.
// If you delete this file, remove `setupFilesAfterEnv` from `jest.config.js`
// Used for __tests__/testing-library.js
// Learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect'
"devDependencies": {
"@testing-library/dom": "^9.0.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/node": "18.11.18",
"@types/testing-library__jest-dom": "^5.14.5",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"tilg": "^0.1.1",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.9.5"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment