I use Yarn to run my Jest tests.
package.json
{
"scripts": {
"test": "jest"
}
}
yarn test
I want to create a GitHub action to run my tests when I merge commits in GitHub. The Node Starter Workflow runs tests with NPM. But I want to run them with Yarn.
How do I create an action to run my tests?
GitHub Actions for YarnThis Action for yarn enables arbitrary actions with the yarn command-line client, including testing packages and publishing to a registry. Please keep in mind that this Action was originally written for GitHub Actions beta (when Docker was the only way of doing things).
Press `a` to run all tests, or run Jest with `--watchAll`. Watch Usage › Press a to run all tests. › Press f to run only failed tests. › Press p to filter by a filename regex pattern. › Press t to filter by a test name regex pattern. › Press q to quit watch mode. › Press Enter to trigger a test run.
You can run Jest directly from the CLI (if it's globally available in your PATH , e.g. by yarn global add jest or npm install jest --global ) with a variety of useful options.
Use the Node Starter Workflow but replace the NPM portion with Yarn commands. For example:
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- run: yarn test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With