Github action to test javascript projects using vitest library, creating feedback message on PR's.
on: pull_request
jobs:
example_test_pr:
runs-on: ubuntu-latest
permissions:
contents: read # (Optional) Use if your repo is private
pull-requests: write # (Required) Permission to comment on PR
name: An example job to test a PR
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Evaluator Step
uses: carlos8v/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
You can customize the action behaviors through custom inputs.
on: pull_request
jobs:
example_test_pr:
runs-on: ubuntu-latest
name: An example job to test a PR
permissions:
contents: read # (Optional) Use if your repo is private
pull-requests: write # (Required) Permission to comment on PR
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Evaluator Step
uses: carlos8v/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
npm-start: true
wait-for: 'http://localhost:3000'
test-coverage: 80
Folder structure should look like this:
.
├── .evaluator
│ └── requirements.json
├── .github
│ └── workflows
│ └── test.yml
└── src
└── ...
requirements.json:
{
"requirements": [
{ "description": "First test", "bonus": false },
{ "description": "Second test", "bonus": false },
{ "description": "Third test", "bonus": true }
]
}
test.spec.js:
describe('First test', () => {
it('unit test1', () => {})
it('unit test2', () => {})
})
describe('Second test', () => {
it('unit test1', () => {})
it('unit test2', () => {})
})
describe('Third test', () => {
it('unit test1', () => {})
it('unit test2', () => {})
})
Name | Description | Default | Required |
---|---|---|---|
token |
Token that is used to create comments | - | ✔️ |
npm-start |
Run npm start and waits to url before testing | false | |
wait-for |
Url that npm start command waits for | http://localhost:3000 | |
test-coverage |
Minimum porcentage of test coverage to pass successfully | 70 |