Skip to content

Commit

Permalink
[refactor] rewrite Core Logic for new Test scripts
Browse files Browse the repository at this point in the history
[add] VS Code debugger configuration
[optimize] upgrade Jest & GitHub actions configuration
[remove] JSDOM patch file
  • Loading branch information
TechQuery committed Aug 2, 2024
1 parent b3f2fca commit 42225fb
Show file tree
Hide file tree
Showing 14 changed files with 365 additions and 491 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

- uses: pnpm/action-setup@v2
with:
version: 8
version: 9
- uses: actions/setup-node@v3
with:
node-version: 18
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ jobs:
Pull-Request:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 9
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org
cache: yarn
- name: Install and Test
run: yarn && yarn test
cache: pnpm
- name: Install Dependencies
run: pnpm i --frozen-lockfile

- name: Test cases
run: npm test
4 changes: 0 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#!/bin/sh

. "$(dirname "$0")/_/husky.sh"

npm test
4 changes: 0 additions & 4 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#!/bin/sh

. "$(dirname "$0")/_/husky.sh"

npm run build
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest",
"type": "node",
"request": "launch",
"port": 9229,
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
7 changes: 0 additions & 7 deletions jest.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { JestConfigWithTsJest } from 'ts-jest';

const config: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
testMatch: ['**/__tests__/**/*.test.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist/']
};
export default config;
112 changes: 55 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
{
"name": "event-submitter-polyfill",
"version": "0.3.2",
"description": "A polyfill for submitter property of form Submit Event, which is written in TypeScript.",
"keywords": [
"submitter",
"submit",
"polyfill",
"form",
"event",
"typescript"
],
"author": "1101077695@qq.com",
"contributors": [
"shiy2008@gmail.com"
],
"license": "LGPL-3.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"source": "source/index.ts",
"homepage": "https://github.com/idea2app/event-submitter-polyfill#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/idea2app/event-submitter-polyfill.git"
},
"bugs": {
"url": "https://github.com/idea2app/event-submitter-polyfill/issues"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"husky": "^9.1.4",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.7",
"patch-package": "^6.5.1",
"postinstall-postinstall": "^2.1.0",
"prettier": "^3.3.3",
"ts-jest": "^29.2.4",
"typescript": "^5.5.4"
},
"resolutions": {
"jsdom": "20.0.3"
},
"prettier": {
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"tabWidth": 4
},
"lint-staged": {
"*.{md,ts,json}": "prettier --write"
},
"scripts": {
"prepare": "husky install",
"test": "jest && lint-staged",
"build": "tsc",
"prepublishOnly": "npm test && npm run build"
}
"name": "event-submitter-polyfill",
"version": "0.4.0",
"description": "A polyfill for submitter property of form Submit Event, which is written in TypeScript.",
"keywords": [
"submitter",
"submit",
"polyfill",
"form",
"event",
"typescript"
],
"author": "1101077695@qq.com",
"contributors": [
"shiy2008@gmail.com"
],
"license": "LGPL-3.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"source": "source/index.ts",
"homepage": "https://github.com/idea2app/event-submitter-polyfill#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/idea2app/event-submitter-polyfill.git"
},
"bugs": {
"url": "https://github.com/idea2app/event-submitter-polyfill/issues"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"husky": "^9.1.4",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.7",
"prettier": "^3.3.3",
"ts-jest": "^29.2.4",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
},
"resolutions": {
"jsdom": "20.0.3"
},
"prettier": {
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
},
"lint-staged": {
"*.{md,ts,json}": "prettier --write"
},
"scripts": {
"prepare": "husky",
"test": "lint-staged && jest",
"build": "tsc",
"prepublishOnly": "npm test && npm run build"
}
}
13 changes: 0 additions & 13 deletions patches/jsdom+20.0.3.patch

This file was deleted.

Loading

0 comments on commit 42225fb

Please sign in to comment.