Skip to content

Commit a539d1d

Browse files
committed
Add jest test framework to explorer
1 parent 6bfb144 commit a539d1d

File tree

5 files changed

+2526
-76
lines changed

5 files changed

+2526
-76
lines changed

mithril-explorer/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ clean:
2626
upgrade: clean install
2727
yarn upgrade next@latest react@latest react-bootstrap@latest react-dom@latest bootstrap@latest \
2828
bootstrap-icons@latest eslint@latest eslint-config-next@latest @reduxjs/toolkit@latest \
29-
next-redux-wrapper@latest react-redux@latest
29+
next-redux-wrapper@latest react-redux@latest @popperjs/core@latest \
30+
jest@latest jest-environment-jsdom@latest @testing-library/react@latest @testing-library/jest-dom@latest

mithril-explorer/__tests__/store.test.js

Whitespace-only changes.

mithril-explorer/jest.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// jest.config.js
2+
const nextJest = require('next/jest')
3+
4+
const createJestConfig = nextJest({
5+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
6+
dir: './',
7+
})
8+
9+
// Add any custom config to be passed to Jest
10+
/** @type {import('jest').Config} */
11+
const customJestConfig = {
12+
// Add more setup options before each test is run
13+
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
14+
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
15+
moduleDirectories: ['node_modules', '<rootDir>/'],
16+
testEnvironment: 'jest-environment-jsdom',
17+
}
18+
19+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
20+
module.exports = createJestConfig(customJestConfig)

mithril-explorer/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
"dev": "next dev",
77
"build": "next build && next export",
88
"start": "next start",
9-
"lint": "next lint"
9+
"lint": "next lint",
10+
"test": "jest --watch",
11+
"test:ci": "jest --ci"
1012
},
1113
"dependencies": {
14+
"@popperjs/core": "^2.11.6",
1215
"@reduxjs/toolkit": "^1.9.0",
1316
"bootstrap": "^5.2.2",
1417
"bootstrap-icons": "^1.9.1",
@@ -20,7 +23,11 @@
2023
"react-redux": "^8.0.5"
2124
},
2225
"devDependencies": {
26+
"@testing-library/jest-dom": "^5.16.5",
27+
"@testing-library/react": "^13.4.0",
2328
"eslint": "^8.27.0",
24-
"eslint-config-next": "^13.0.2"
29+
"eslint-config-next": "^13.0.2",
30+
"jest": "^29.3.1",
31+
"jest-environment-jsdom": "^29.3.1"
2532
}
2633
}

0 commit comments

Comments
 (0)