Skip to content

[Startup MVP recipes #11] Nest.js Run Unit Tests with Github Actions

If interested, please also check previous two articles on setting up the tests:

References

Config

On PR open, we will trigger this github action workflow on the cloud and let it run the checks remotely.

name: Nest.js Jest CI

on:
  push:
    branches: [dev]
  pull_request:
    types: [opened, reopened, synchronize]
    branches: [dev]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x]

    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci
      - run: npm run prebuild
      - run: NODE_ENV=development npm run lint
      - run: NODE_ENV=development npm run build
      - run: NODE_ENV=development npm run test

Demo

Github Action page
Warnings are also shown on the files

Leave a Reply

Your email address will not be published. Required fields are marked *