Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Feature/louis setup jest (#38)
Browse files Browse the repository at this point in the history
* test: setup jest for test

* ci: add pre-push script

* chore: fix typo
  • Loading branch information
louis-lemon authored Jan 8, 2024
1 parent b69aaa4 commit dba808f
Show file tree
Hide file tree
Showing 6 changed files with 1,862 additions and 82 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ Thumbs.db


*.js
!jest.config.json
!_*.js
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx jest --watchAll=false
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Dockerfile
# jest
.jest.init.js
coverage
jest.config.js
jest.config.json
__mocks__
__snapshots__
__tests__
Expand Down
10 changes: 10 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"preset": "ts-jest",
"testEnvironment": "node",
"rootDir": "./",
"coverageDirectory": "<rootDir>/coverage",
"collectCoverageFrom": ["<rootDir>/src/**/*.ts", "!<rootDir>/src/**/constant.ts", "!<rootDir>/src/**/type.ts"],
"testPathIgnorePatterns": ["<rootDir>/node_modules"],
"coverageReporters": ["html", "json"],
"testMatch": ["<rootDir>/src/**/*.spec.ts", "<rootDir>/src/**/*.test.ts"]
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"start": "tsc -w",
"build": "pnpm clean && tsup src/index.ts",
"release": "pnpm run build && changeset publish",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "jest --passWithNoTests --updateSnapshot --watchAll",
"test:coverage": "jest --passWithNoTests --updateSnapshot --coverage",
"fix:prettier": "prettier \"src/**/*.ts\" --write",
"fix:lint": "eslint src --ext .ts --fix",
"changeset": "npx changeset",
Expand Down Expand Up @@ -44,8 +45,11 @@
"eslint": "^8.45.0",
"eslint-plugin-unused-imports": "^3.0.0",
"husky": "^8.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"tsup": "^7.1.0",
"typescript": "^5.1.6"
}
Expand Down
Loading

0 comments on commit dba808f

Please sign in to comment.