Skip to content

Commit d3e7a47

Browse files
authored
Added jest tests (#17)
* test: add Jest configuration and initial test for splitConstants function
1 parent 0833a49 commit d3e7a47

File tree

6 files changed

+2959
-219
lines changed

6 files changed

+2959
-219
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@ name: Release
22
on:
33
push:
44
branches:
5-
- master
5+
- '**'
6+
pull_request:
67

78
permissions:
8-
contents: read # for checkout
9+
contents: write
10+
checks: write
11+
pull-requests: write
912

1013
jobs:
1114
build:
1215
name: Build
1316
runs-on: ubuntu-latest
1417
permissions:
15-
contents: read # for checkout
18+
checks: write # for jest-coverage-report
19+
contents: write # for checkout
20+
pull-requests: write # for jest-coverage-report
1621
steps:
1722
- name: Checkout
1823
uses: actions/checkout@v3
@@ -26,6 +31,12 @@ jobs:
2631
run: npm clean-install
2732
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
2833
run: npm audit signatures
34+
- name: Jest Coverage Report
35+
uses: ArtiomTr/jest-coverage-report-action@v2
36+
with:
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
skip-step: install
39+
test-script: npm test -- --coverage
2940
- name: Build and test
3041
run: npm run prepublishOnly
3142

@@ -53,6 +64,8 @@ jobs:
5364
run: npm clean-install
5465
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
5566
run: npm audit signatures
67+
- name: Run tests with coverage
68+
run: npm run test:coverage
5669
- name: Release
5770
env:
5871
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dist
66
npm-debug.log*
77
yarn.lock
88
.vscode/launch.json
9+
coverage/

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/test'],
5+
testMatch: ['**/test/**/*.test.ts', '**/test/**/*.spec.ts'],
6+
transform: {
7+
'^.+\\.ts$': 'ts-jest',
8+
},
9+
collectCoverageFrom: [
10+
'credentials/**/*.ts',
11+
'nodes/**/*.ts',
12+
'!**/*.node.ts',
13+
'!**/*.credentials.ts',
14+
],
15+
moduleFileExtensions: ['ts', 'js', 'json'],
16+
};

0 commit comments

Comments
 (0)