Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Dev Ops react-scripts test hangs forever

I'm trying to run my react app's tests in Azure Dev Ops I can't figure out how to make the execution stop after the tests run. It just hangs there, holding the pipeline in running mode forever. It's a simple create-react-app application which has a couple of tests. Below is my pipeline's YAML:

trigger: none

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

- script: npm run citest

- task: PublishPipelineArtifact@0
  inputs:
    artifactName: 'react'
    targetPath: './build'

I had just "- script: npm test" on the test step but, following instructions in the facebook github I created a new test script (called citest): set CI=true && react-scripts test a but it still does not work. I get the below output in the dev ops console and the task just keeps running forever:

> set CI=true && react-scripts test a
PASS src/components/landing/landing.test.js (6.008s)
PASS src/components/navbar/NavBar.test.js
PASS src/components/app/App.test.js
Test Suites: 3 passed, 3 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        7.573s
Ran all test suites matching /a/i.

I've run out of ideas on what to try - any help is appreciated!

like image 206
YuriW Avatar asked Jul 15 '19 21:07

YuriW


1 Answers

Update the script like this:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "citest":"CI=true react-scripts test"
  },
like image 148
starian chen-MSFT Avatar answered Sep 28 '22 04:09

starian chen-MSFT