Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable testing by 'jest' on CI #12

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI on pull request

on:
pull_request:
push:
branches:
- main

jobs:
ci:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install pnpm
run: npm install -g pnpm

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Run tests
run: pnpm test
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: It seems advisable to pin the minor version as well to ensure compatibility and stability.

Suggested change
22
22.3.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixing "minor" version makes sense.

but I'm planning to free "patch" version to apply security patch automatically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pinned at 22.3: a814394

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that sounds like a good plan.

13 changes: 13 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
],
"@babel/preset-typescript"
]
}
27 changes: 27 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var esmModules = [
"chalk",
"ora",
"cli-cursor",
"restore-cursor",
"log-symbols",
"is-unicode-supported",
"strip-ansi",
"ansi-regex",
"is-interactive",
"stdin-discarder",
];

module.exports = {
preset: "ts-jest/presets/js-with-babel",
testEnvironment: "node",
transform: {
"^.+\\.[tj]sx?$": "babel-jest",
},
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transformIgnorePatterns: [
`node_modules/(?!(?:.pnpm/)?(${esmModules.join('|')}))`,
],
testMatch: ["**/?(*.)+(test).[tj]s?(x)"],
};
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"predev": "run-s clean",
"clean": "rm -rf dist",
"typecheck": "tsc --noEmit",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"keywords": [
"aws",
Expand Down Expand Up @@ -59,8 +59,16 @@
"ora": "^6.1.2"
},
"devDependencies": {
"@babel/core": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"@babel/preset-typescript": "^7.24.6",
"@types/jest": "^29.5.12",
"@types/node": "^18.11.18",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"js-with-babel": "link:ts-jest/presets/js-with-babel",
"npm-run-all": "^4.1.5",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.1",
"tsup": "^6.5.0",
"typescript": "^4.9.4"
Expand Down
Loading