-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mnrendra/unit-test
Setup test libraries and initiate unit-test example.
- Loading branch information
Showing
6 changed files
with
11,518 additions
and
4,076 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// jest.config.js | ||
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 | ||
/** @type {import('jest').Config} */ | ||
const customJestConfig = { | ||
// Add more setup options before each test is run | ||
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work | ||
moduleDirectories: ['node_modules', '<rootDir>/'], | ||
moduleNameMapper: { | ||
// style | ||
"^@styles/(.*)": "<rootDir>/styles/$1", | ||
// ui | ||
"^@ui": "<rootDir>/ui", | ||
"^@ui/(.*)": "<rootDir>/ui/$1", | ||
// components | ||
"^@components": "<rootDir>/components", | ||
"^@components/(.*)": "<rootDir>/components/$1", | ||
// utils | ||
"^@utils": "<rootDir>/utils", | ||
"^@utils/(.*)": "<rootDir>/utils/$1", | ||
// store | ||
"^@store": "<rootDir>/store", | ||
"^@store/(.*)": "<rootDir>/store/$1", | ||
}, | ||
testEnvironment: 'jest-environment-jsdom', | ||
// load `jest.setup.js` to load `import '@testing-library/jest-dom'` | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'] | ||
} | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
module.exports = createJestConfig(customJestConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// allows you to do things like: | ||
// expect(element).toHaveTextContent(/react/i) | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom' |
Oops, something went wrong.
a464f51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextjs-demo – ./
nextjs-demo-umber-two.vercel.app
nextjs-demo-mnrendra.vercel.app
nextjs-demo-git-main-mnrendra.vercel.app