npm test never stops executing

I used create-react-app to bootstrap a new project and left it as it is by default.

Added GitHub actions config for node.js:

name: Build and Deploy
on:
  push:
    branches:
      - master
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Setup Node
        uses: actions/setup-node@v1
        with:
          node-version: '10.x'
      - run: npm ci
      - run: npm test

The code never passes the npm test step.

What am I doing wrong?

It seems that when you execute the command npm test , you should explicitly set the environment variable CI , no matter its value is true or false.

You can try the below 2 methods to set this environment variable:

  • Set CI directly in the command line, for example on Linux, macOS (Bash).

    CI=true npm test

  • Define CI as an environment variable in the workflow.

    env:
     CI: true

We can define it on workflow level, job level or step level, so that it can be available for different scopes.

4 Likes

Do you need both? CI=true npm test works but just setting the env var hangs when you add another command after the npm test

      - run: npm test
      - run: echo hangs in the line above even though the env var is set
      env:
          CI: true

      - run: CI=true npm test
      - run: echo works and pipeline continues
      env:
          CI: true

When just using env and I run -run: env I don’t see the CI var

1 Like

when my workflow runs i have everything setup as you said but though it takes forever to run test

on local it works fine but on github it takes forever