Skip to content

Commit

Permalink
test: write test in JavaScript (#108)
Browse files Browse the repository at this point in the history
* test: map imported module from the distribution files

* chore: remove @jest/globals, @types/jest, and ts-jest from dependencies

* test: modify test files to JavaScript

* test: remove `testMatch` option in Jest (redundant)

* build: remove `tsconfig.eslint.json`

* ci(test): set `--experimental-vm-modules` only on `Test Package` step instead
  • Loading branch information
threeal authored Dec 11, 2023
1 parent ad6a9d3 commit 96089ee
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["tsconfig.eslint.json"]
"project": ["tsconfig.json"]
},
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc"],
"rules": {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
env:
NODE_OPTIONS: --experimental-vm-modules
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -34,6 +32,8 @@ jobs:

- name: Test Package
run: yarn test
env:
NODE_OPTIONS: --experimental-vm-modules

test-action:
name: Test Action
Expand Down
7 changes: 1 addition & 6 deletions jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
"statements": 100
}
},
"extensionsToTreatAsEsm": [".ts", ".mts"],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.mjs$": "$1.mts"
},
"testMatch": ["**/*.test.ts"],
"transform": {
"^.+\\.m?ts$": ["ts-jest", { "useESM": true }]
"^(\\.{1,2}/.*)\\.mjs$": "<rootDir>/dist/$1.mjs"
}
}
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
"scripts": {
"bundle": "tsc && ncc build dist/main.mjs -o main",
"check": "sort-package-json && prettier --write . !main !README.md && eslint src",
"test": "jest"
"test": "tsc && jest"
},
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.10",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
Expand All @@ -25,7 +23,6 @@
"jest": "^29.7.0",
"prettier": "^3.1.0",
"sort-package-json": "^2.6.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
},
"packageManager": "[email protected]"
Expand Down
File renamed without changes.
4 changes: 0 additions & 4 deletions tsconfig.eslint.json

This file was deleted.

3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"target": "ES2022",
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["**/*.test.*"]
"include": ["src"]
}
79 changes: 5 additions & 74 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96089ee

Please sign in to comment.