Skip to content

Commit 998013b

Browse files
committed
[DEV]: add Jest and RTL and remove nanoid
1 parent 37b9f8e commit 998013b

File tree

4 files changed

+2547
-112
lines changed

4 files changed

+2547
-112
lines changed

jest.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const nextJest = require("next/jest");
2+
const createJestConfig = nextJest({
3+
dir: "./"
4+
});
5+
const customJestConfig = {
6+
moduleDirectories: ["node_modules", "<rootDir>"],
7+
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
8+
testEnvironment: "jest-environment-jsdom",
9+
extensionsToTreatAsEsm: [".ts"]
10+
// transformIgnorePatterns: ["/node_modules/(?!(foo|bar)/)"]
11+
};
12+
module.exports = createJestConfig(customJestConfig);

jest.setup.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Optional: configure or set up a testing framework before each test.
2+
// If you delete this file, remove `setupFilesAfterEnv` from `jest.config.js`
3+
4+
// Used for __tests__/testing-library.js
5+
// Learn more: https://github.com/testing-library/jest-dom
6+
import "@testing-library/jest-dom/extend-expect";

package.json

+14-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint"
9+
"lint": "next lint",
10+
"test": "jest --watch",
11+
"test:ci": "jest --ci"
1012
},
1113
"dependencies": {
1214
"@types/node": "18.11.9",
@@ -16,12 +18,21 @@
1618
"eslint-config-next": "13.0.5",
1719
"gray-matter": "^4.0.3",
1820
"highlight.js": "^11.7.0",
19-
"nanoid": "^4.0.0",
2021
"next": "13.0.5",
2122
"next-mdx-remote": "^4.2.0",
2223
"react": "18.2.0",
2324
"react-dom": "18.2.0",
2425
"rehype-highlight": "^6.0.0",
25-
"typescript": "4.9.3"
26+
"typescript": "4.9.3",
27+
"uuid": "^9.0.0"
28+
},
29+
"devDependencies": {
30+
"@testing-library/jest-dom": "^5.16.5",
31+
"@testing-library/react": "^13.4.0",
32+
"@testing-library/user-event": "^14.4.3",
33+
"@types/jest": "^29.2.4",
34+
"@types/uuid": "^9.0.0",
35+
"jest": "^29.3.1",
36+
"jest-environment-jsdom": "^29.3.1"
2637
}
2738
}

0 commit comments

Comments
 (0)