title: Running mocha test with Azure pipelines and Docker
body: <p>I am very new to CICD.</p>
  
  <p>I have an Azure web app running a Docker container built from an Express Nodejs image. </p>
  
  <p>My current flow is minimalistic. I have an Azure-pipelines.yml file that looks like </p>
  
  <pre><code>trigger:
  - master
  
  pool:
    vmImage: 'ubuntu-latest'    
  
  - task: AzureCLI@1
    inputs:
      azureSubscription: 'xxxxxx'
      scriptLocation: 'inlineScript'
      inlineScript: 'az acr build --registry registry123 --image image123:latest --file Dockerfile .'
  </code></pre>
  
  <p>And a dockerfile that looks like</p>
  
  <pre><code>FROM node:10
  
  WORKDIR /poc/microservices
  
  COPY package*.json ./
  
  RUN npm install
  
  COPY . .
  
  EXPOSE 3000
  
  CMD [ "node", "server.js" ]
  </code></pre>
  
  <p>Now I have added some mocha tests that I can run with <code>npm test</code>, and these are running fine locally. </p>
  
  <p>Now I want to add these to the pipeline so that it doesnt build the image if the tests are failing. </p>
  
  <p>I have a mocha.opts file where I defined <code>--reporter mocha-junit-reporter</code> and the tests are using an <code>process.env.ENDPOINT</code> variable.</p>
  
  <p>So my question is how do I add the command to the pipeline?</p>
  
  <p>Do I simply add </p>
  
  <pre><code>- script: npm install
  - script: npm test
  </code></pre>
  
  <p>to azure-pipelines.yml and then configure the ENDPOINT variable in the build variables in azure devOps portal? </p>
  
  <p>If so, is it not a problem that I am running then twice <code>npm install</code>? once in Azure, and another time in Docker?</p>