Skip to main content

Build and Test a Node.js App in Azure DevOps

Hands-On Lab


Photo of Chad Crowell

Chad Crowell

DevOps Training Architect II in Content





In this hands-on lab, you will be taking an existing Node.js app and running it through a DevOps pipeline in Azure Pipelines. Also within Azure pipelines, you will modify the deployment YAML in order to specify the version of Node.js and publish the build results to Azure Test Plans.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Build and Test a Node.js App in Azure DevOps


We are a DevOps engineer at Northstar Corp. We have just been contacted by the developers of a new Node.js application. They explain they would like to integrate their code, as there are many different developers working on this project and they want to ensure one developer's code changes don't break the main application. The main application is running a certain version of Node.js, and they would like to test the application using npm to ensure that the packages run accordingly with the provided test script specified in the package.json file.

Connecting to the Lab

  1. Log in to the Azure Portal using the credentials provided on the lab instructions page.

Create a New Azure DevOps Organization

  1. Click on All services in the left-hand menu.

  2. Run a search for "DevOps" and select Azure DevOps.

  3. Click on the My Azure DevOps Organizations link.

  4. Leave the default values and click Continue.

  5. Click Create new organization.

  6. Uncheck the checkbox and then click Continue.

  7. Leave the default name for the new DevOps organization and select Central US as a location to host your project.

  8. Click Continue.

  9. Enter "nodejs" for the Project name.

  1. Select Public.

  2. Click + Create project.

Create a Repository for the Application in an Azure Repo

  1. On the left-hand menu, click Repos.

  2. Click default nodejs repository.

  3. Click Import.

  4. Under Clone URL, enter

  5. Click Import.

Create a New Pipeline and Run the First Build

  1. On the left-hand menu, click Pipelines.

  2. Click New pipeline.

  3. Click Azure Repos Git.

  4. Click nodejs.

  5. Click Node.js.

  6. Click Save and run.

  7. On the pop-up window, leave the Commit message as the default, and make sure Commit directly to the master branch is selected.

  8. Click Save and run.

  9. Wait for the build to complete and verify everything ran successfully.

Edit the Build to Include a Specific Version of Node.js and Publish the Test Results

  1. In the left-hand menu, click Repos.

  2. Click azure-pipelines.yml.

  3. Click Edit.

  4. Change the versionSpec line to the following.

    versionSpec: '10.14'
  5. Click Commit at the top of the edit window.

  6. Under Comment enter "changed version of node.js to 10.14".

  7. Click Commit.

  8. Click tests.

  9. Click test.js and verify the presence of the test.

  1. Click package.json and verify JUnit is installed.

  2. In the left-hand menu, click Pipelines.

  3. In the upper-right, click Edit.

  4. Click the bottom of the file.

  5. On the Tasks frame, search for "Publish test results".

  6. Click Publish Test Results.

  7. Under Test results files, enter "**/TEST-RESULTS.xml"

  8. Click Add.

  9. Click Save in the upper-right.

  10. Under Commit message enter "added a task to publish test results".

  11. Click Save.

  12. In the right-hand menu, under Pipelines, click Builds.

  13. Click added a task to publish test results.

  14. Wait for the build to complete, and then click PublishTestResults.

  15. Close the window.

  16. In the right-hand menu, click Test Plans.

  17. Click Runs.

  18. Click the only test row to see the results.


Congratulations, you've completed this hands-on lab!