-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Test Suite, Achieve 80% Coverage (#41)
## Description Of Change This PR adds a testing suite to this repository, achieving 80%+ test coverage of all relevant client files. While working on the test suite, I ran across an old method on the client `performWorkflowStep` which was broken. As far as we can tell, no one uses this method and it doens't fit into the API surface of our Staking API anymore. So I've gone ahead and removed it. This makes this PR a breaking change. I attempted to modify as little actual client code as possible while making these changes, focusing only on the testing and the appropriate coverage. Slight alterations were made, where necessary, to achieve maximal coverage (ex: exporting a method). As you can see in the image attached in a comment, we've achieved 80%+ on statements and lines. We can still improve coverage for branches and funcs. But considering we started at 0 across the board, this is a huge improvement. The coverage image I posted can be regenerated via `npm run coverage`. ## Testing Procedure Added dozens of tests and achieved 80%+ test coverage :)
- Loading branch information
Showing
20 changed files
with
5,333 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: TypeScript Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "23.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Run npm ci | ||
run: npm ci | ||
- name: Run tests | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,8 @@ dist/ | |
|
||
node_modules/ | ||
|
||
# VSCode configuration | ||
.vscode | ||
|
||
docs/**/*.json | ||
|
||
# code coverage output | ||
coverage | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"require": [ | ||
"ts-node/register" | ||
], | ||
"spec": "src/**/*.test.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"extends": "@istanbuljs/nyc-config-typescript", | ||
"all": true, | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"exclude": [ | ||
"src/**/*.test.ts", | ||
"src/**/index.ts", | ||
"node_modules", | ||
"src/gen" | ||
], | ||
"reporter": [ | ||
"text", | ||
"html" | ||
], | ||
"check-coverage": true, | ||
"lines": 80, | ||
"statements": 80 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"markdownlint.config": { | ||
"MD033": false, | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnPaste": true, | ||
"editor.formatOnType": false, | ||
"files.autoSave": "onFocusChange", | ||
"cSpell.words": [ | ||
"automerge", | ||
"holesky", | ||
"nonroutine", | ||
"solana", | ||
"txsigner", | ||
"unstake" | ||
], | ||
"typescript.updateImportsOnFileMove.enabled": "always", | ||
"javascript.updateImportsOnFileMove.enabled": "always", | ||
"vs-code-prettier-eslint.prettierLast": false, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint" | ||
}, | ||
"[json]": { | ||
"editor.defaultFormatter": "vscode.json-language-features" | ||
}, | ||
"[jsonc]": { | ||
"editor.defaultFormatter": "vscode.json-language-features" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint" | ||
}, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"files.insertFinalNewline": true, | ||
} |
Oops, something went wrong.