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

Add JavaScript tests npm command and GitHub workflow #80

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading