Skip to content

Commit 03af3f5

Browse files
refactor: add the ts config
1 parent 68d08cc commit 03af3f5

File tree

4 files changed

+1704
-26
lines changed

4 files changed

+1704
-26
lines changed

jest.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
// eslint-disable-next-line @typescript-eslint/no-var-requires
7+
const nextJest = require("next/jest");
8+
9+
const createJestConfig = nextJest({
10+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
11+
dir: "./",
12+
});
13+
14+
// Add any custom config to be passed to Jest
15+
const config = {
16+
coverageProvider: "v8",
17+
testEnvironment: "jsdom",
18+
// Add more setup options before each test is run
19+
// setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
20+
moduleNameMapper: {},
21+
};
22+
23+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
24+
module.exports = createJestConfig(config);

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"lint": "eslint --ignore-path .eslintignore \"./**/*.{ts,tsx,js}\"",
1010
"prettier-format": "prettier --config .prettierrc 'src/**/*.{ts,tsx,js,jsx}' --write",
1111
"check-branch-name": "./check_branch_name.sh",
12-
"prepare": "npx husky install && chmod +x .husky/* && chmod +x ./check_branch_name.sh"
12+
"prepare": "npx husky install && chmod +x .husky/* && chmod +x ./check_branch_name.sh",
13+
"test": "jest --silent"
1314
},
1415
"dependencies": {
1516
"@coingecko/cryptoformat": "^0.5.4",
@@ -87,7 +88,10 @@
8788
"@svgr/webpack": "^6.5.1",
8889
"@tailwindcss/line-clamp": "^0.4.2",
8990
"@tailwindcss/typography": "^0.5.9",
91+
"@testing-library/jest-dom": "^6.4.2",
92+
"@testing-library/react": "^15.0.2",
9093
"@types/dompurify": "^3.0.0",
94+
"@types/jest": "^29.5.12",
9195
"@types/lodash": "^4.14.192",
9296
"@types/lodash.debounce": "^4.0.7",
9397
"@types/lodash.uniqby": "^4.7.7",
@@ -97,6 +101,8 @@
97101
"autoprefixer": "^10.4.14",
98102
"eslint-config-prettier": "^8.7.0",
99103
"husky": "^8.0.3",
104+
"jest": "^29.7.0",
105+
"jest-environment-jsdom": "^29.7.0",
100106
"lint-staged": "^13.2.0",
101107
"postcss": "^8.4.24",
102108
"prettier": "^2.8.8",

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"react": ["./node_modules/@types/react"]
2020
}
2121
},
22-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/components/sections/learning-modules/_partials/MarkDown.jsx"],
22+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/components/sections/learning-modules/_partials/MarkDown.jsx", "jest.config.js"],
2323
"exclude": ["node_modules"]
2424
}

0 commit comments

Comments
 (0)