Close full mode

Run unit test when creating a PR

Git RepositoryEdit on Github

Run Jest unit test

  • We need to enable Run workflows from fork pull requests to get workflow triggered.
    • Go to setting of enterprise, organization or repository settings.
    • Example URL of an organization settings URL:
    • Go to Actions > Fork pull request workflows section
    • Check Run workflows from fork pull requests
    • Click Save

Enable run workflows from fork pull requests

  • Example of workflow:
name: Run unit test workflow
on: pull_request # Pull request on any branches
NODE_VERSION: 14.x # Set this to change the Node.js version to use
name: Run unit test
# Find more virtual environment.
runs-on: ubuntu-18.04
- name: Checkout the latest source code from the current branch
uses: actions/checkout@v2
- name: Use Node.js version ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
node-version: ${{ env.NODE_VERSION }}
- name: Run all test cases with Jest
# Yarn Yarn 1.22.5 is already installed
working-directory: src # We must be in a path that has yarn workspaces package.json
run: |
echo ${{ github.repository }}
git rev-parse HEAD
git log -1
node --version
yarn --version
yarn install
yarn run test

Result in GitHub PR checks

Result in GitHub PR checks

Run xUnit unit test

Coming soon

Loading comments...