Skip to content

Commit d60509d

Browse files
author
devgioele
committed
run tests using vitest
1 parent fc10df2 commit d60509d

5 files changed

Lines changed: 35 additions & 10 deletions

File tree

.eslintcache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"/Users/the-anarcho-primitivist/code/react-pagination/jest-setup.ts":"1","/Users/the-anarcho-primitivist/code/react-pagination/src/index.ts":"2","/Users/the-anarcho-primitivist/code/react-pagination/src/useInMemoryRouterQuery.ts":"3","/Users/the-anarcho-primitivist/code/react-pagination/src/useNextRouterQuery.ts":"4","/Users/the-anarcho-primitivist/code/react-pagination/src/useQuery.ts":"5","/Users/the-anarcho-primitivist/code/react-pagination/src/useReactRouterQuery.ts":"6","/Users/the-anarcho-primitivist/code/react-pagination/src/vitest.ts":"7","/Users/the-anarcho-primitivist/code/react-pagination/vite.config.ts":"8"},{"size":35,"mtime":1687784551871,"results":"9","hashOfConfig":"10"},{"size":116,"mtime":1689576597280,"results":"11","hashOfConfig":"10"},{"size":411,"mtime":1689576530547,"results":"12","hashOfConfig":"10"},{"size":819,"mtime":1689576530547,"results":"13","hashOfConfig":"10"},{"size":1256,"mtime":1689576530547,"results":"14","hashOfConfig":"10"},{"size":1388,"mtime":1689576530547,"results":"15","hashOfConfig":"10"},{"size":35,"mtime":1689620493485,"results":"16","hashOfConfig":"10"},{"size":199,"mtime":1689620373796,"results":"17","hashOfConfig":"10"},{"filePath":"18","messages":"19","suppressedMessages":"20","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"8y9yfn",{"filePath":"21","messages":"22","suppressedMessages":"23","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","suppressedMessages":"26","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"27","messages":"28","suppressedMessages":"29","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","suppressedMessages":"32","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"33","messages":"34","suppressedMessages":"35","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"36","messages":"37","suppressedMessages":"38","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"39","messages":"40","suppressedMessages":"41","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/the-anarcho-primitivist/code/react-pagination/jest-setup.ts",[],[],"/Users/the-anarcho-primitivist/code/react-pagination/src/index.ts",[],[],"/Users/the-anarcho-primitivist/code/react-pagination/src/useInMemoryRouterQuery.ts",[],[],"/Users/the-anarcho-primitivist/code/react-pagination/src/useNextRouterQuery.ts",[],[],"/Users/the-anarcho-primitivist/code/react-pagination/src/useQuery.ts",[],[],"/Users/the-anarcho-primitivist/code/react-pagination/src/useReactRouterQuery.ts",[],[],"/Users/the-anarcho-primitivist/code/react-pagination/src/vitest.ts",[],[],"/Users/the-anarcho-primitivist/code/react-pagination/vite.config.ts",[],[]]

.eslintrc.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,30 @@
44
"browser": true,
55
"node": true
66
},
7-
"plugins": ["@typescript-eslint", "react", "react-hooks", "jest"],
7+
"plugins": ["@typescript-eslint", "react", "react-hooks"],
88
"extends": [
9+
"eslint:recommended",
910
"plugin:@typescript-eslint/recommended",
11+
"plugin:react/recommended",
12+
"plugin:react/jsx-runtime",
1013
"plugin:import/recommended",
1114
"plugin:import/typescript",
12-
"plugin:jest/recommended",
1315
"plugin:prettier/recommended"
1416
],
1517
"parserOptions": {
1618
"sourceType": "module",
1719
"ecmaVersion": 2018
1820
},
21+
"settings": {
22+
"react": {
23+
"version": "detect"
24+
},
25+
"import/resolver": {
26+
"node": {
27+
"paths": ["./"]
28+
}
29+
}
30+
},
1931
"rules": {
2032
"react-hooks/rules-of-hooks": "error",
2133
"react-hooks/exhaustive-deps": "error",

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
"build:esm": "tsc -p tsconfig.esm.json",
1616
"build:cjs": "tsc -p tsconfig.cjs.json",
1717
"build:types": "tsc -p tsconfig.types.json",
18-
"lint": "eslint --ext js,ts,tsx src",
18+
"lint": "eslint --ext js,ts,tsx --cache .",
1919
"lint:fix": "npm run lint -- --fix",
20+
"test": "vitest run --passWithNoTests",
21+
"test:watch": "vitest watch --passWithNoTests",
2022
"typecheck": "tsc --noEmit",
21-
"test": "jest --verbose --passWithNoTests",
23+
"checks": "npm run test && npm run lint && npm run typecheck",
2224
"prepare": "npm run build",
2325
"prepublishOnly": "npm run test && npm run lint",
2426
"version": "npm run test && npm run lint && git add -A src",
@@ -50,7 +52,6 @@
5052
"devDependencies": {
5153
"@testing-library/jest-dom": "^5.16.5",
5254
"@testing-library/react": "^13.4.0",
53-
"@types/jest": "^28.1.3",
5455
"@types/react": "^18.0.0",
5556
"@types/react-dom": "^18.0.0",
5657
"@types/react-router-dom": "^5.3.3",
@@ -59,21 +60,20 @@
5960
"eslint": "^8.18.0",
6061
"eslint-config-prettier": "^8.5.0",
6162
"eslint-plugin-import": "^2.26.0",
62-
"eslint-plugin-jest": "^26.5.3",
6363
"eslint-plugin-prettier": "^4.1.0",
6464
"eslint-plugin-react": "^7.32.2",
6565
"eslint-plugin-react-hooks": "^4.6.0",
66-
"jest": "^28.1.1",
67-
"jest-environment-jsdom": "^28.1.1",
66+
"jsdom": "^22.1.0",
6867
"next": "^13.1.3",
6968
"next-router-mock": "^0.7.4",
7069
"prettier": "^2.7.1",
7170
"react": "^18.0.0",
7271
"react-dom": "^18.0.0",
7372
"react-router-dom": "^6.7.0",
7473
"rimraf": "^5.0.1",
75-
"ts-jest": "^28.0.5",
76-
"typescript": "^5.1.6"
74+
"typescript": "^5.1.6",
75+
"vite": "^4.4.4",
76+
"vitest": "^0.33.0"
7777
},
7878
"peerDependencies": {
7979
"next": "^12.0.0 || ^13.0.0",

src/vitest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom'

vite.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference types="vitest" />
2+
3+
import { defineConfig } from 'vite'
4+
5+
export default defineConfig({
6+
test: {
7+
globals: true,
8+
environment: 'jsdom',
9+
setupFiles: './src/vitest.ts',
10+
},
11+
})

0 commit comments

Comments
 (0)