Skip to content

Commit

Permalink
Add JavaScript tests npm command and GitHub workflow (#80)
Browse files Browse the repository at this point in the history
* Rename current tests to 'Ruby on Rails Tests'

* Add docs for the local execution of the JavaScript tests

* Add GitHub actions workflow configuration for the JavaScript tests
  • Loading branch information
andreslucena authored May 13, 2024
1 parent 1b907ea commit 6a02d0f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test-javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "[CI] JavaScript Tests"

on:
push:
branches:
- main
pull_request:

env:
CI: "true"
NODE_VERSION: 16.9.1

jobs:
test-report:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Get npm cache directory path
id: npm-cache-dir-path
run: echo "::set-output name=dir::$(npm get cache)-vocdoni"

- uses: actions/cache@v2
id: npm-cache
with:
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-
- run: npm ci
- run: npm run test
name: Node test
env:
CODECOV: 1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[CI] Tests"
name: "[CI] Ruby on Rails Tests"

on:
push:
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ can add these environment variables to the root directory of the project in a
file named `.rbenv-vars`. In this case, you can omit defining these in the
commands shown above.

We also have some tests for the Javascript code. To run them, you can use the
following commands:

```bash
npm ci
npm run test
```

### Test code coverage

Code coverage report is generated automatically after running the test suite, in a folder
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "ENV=dev WALLET=random node node-wrapper/test_census.mjs",
"lint": "eslint -c .eslintrc.json --ext .js --ext .mjs app/packs/ node-wrapper/",
"lint-fix": "eslint -c .eslintrc.json --ext .js --ext .mjs app/packs/ node-wrapper/ --fix",
"stylelint": "stylelint **/*.scss",
Expand Down

0 comments on commit 6a02d0f

Please sign in to comment.