Skip to content

Commit 5de68e8

Browse files
authored
Merge pull request #407 from honyanya/feature/add_jest
[add] Suggestion: jest を追加してテストコードを書く
2 parents 74e07b4 + 0682eb6 commit 5de68e8

File tree

4 files changed

+1365
-40
lines changed

4 files changed

+1365
-40
lines changed

jest.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const nextJest = require('next/jest')
2+
3+
const createJestConfig = nextJest({
4+
dir: './',
5+
})
6+
7+
/** @type {import('jest').Config} */
8+
const customJestConfig = {
9+
moduleDirectories: ['node_modules', '<rootDir>/'],
10+
11+
moduleNameMapper: {
12+
'@/(.*)$': '<rootDir>/src/$1',
13+
},
14+
testEnvironment: 'jest-environment-jsdom',
15+
}
16+
17+
module.exports = createJestConfig(customJestConfig)

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"lint": "next lint",
1010
"format": "prettier --write --ignore-path .gitignore './**/*.{js,ts,tsx,json,css}'",
1111
"storybook": "start-storybook -p 6006",
12-
"build-storybook": "build-storybook"
12+
"build-storybook": "build-storybook",
13+
"test": "jest --watch",
14+
"test:ci": "jest"
1315
},
1416
"dependencies": {
1517
"@primer/octicons-react": "17.12.0",
@@ -37,6 +39,7 @@
3739
"@storybook/react": "6.5.16",
3840
"@storybook/testing-library": "0.0.13",
3941
"@types/gtag.js": "0.0.12",
42+
"@types/jest": "29.4.0",
4043
"@types/node": "18.11.18",
4144
"@types/react": "18.0.28",
4245
"@types/uuid": "9.0.0",
@@ -46,10 +49,13 @@
4649
"eslint-config-next": "13.1.6",
4750
"eslint-config-prettier": "8.6.0",
4851
"eslint-plugin-tailwindcss": "3.8.3",
52+
"jest": "29.4.3",
53+
"jest-environment-jsdom": "29.4.3",
4954
"postcss": "8.4.21",
5055
"prettier": "2.8.4",
5156
"storybook": "6.5.16",
5257
"tailwindcss": "3.2.7",
58+
"ts-jest": "29.0.5",
5359
"typescript": "4.9.5"
5460
},
5561
"prettier": {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { toHtmlUrl } from '../contributions';
2+
3+
describe('toHtmlUrl', () => {
4+
test('check replace', () => {
5+
expect(toHtmlUrl("https://api.github.com/repos/swfz/tools")).toBe("https://github.com/swfz/tools")
6+
});
7+
});
8+

0 commit comments

Comments
 (0)