October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk7 min

How to Run Cypress Tests in an Azure DevOps Pipeline

A practical Azure Pipelines YAML example for installing Cypress, waiting for your app, running end-to-end tests, publishing JUnit results, and keeping diagnostics.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run Cypress in Azure Pipelines by selecting a compatible Node.js version, installing the project’s locked dependencies with npm ci, starting the application and waiting until it is ready, then running npx cypress run. Publish JUnit output and retain screenshots or videos if you need results and diagnostics after the build agent is discarded. The YAML below is a practical starting point; adjust its scripts and URLs to your application.

Azure Pipelines YAML for Cypress

This example uses Microsoft-hosted Ubuntu, Node.js 24, npm, a readiness check, JUnit XML, and pipeline artifacts. Cypress’s maintained Azure sample uses ubuntu-latest and NodeTool@0 with 24.x; choose a Node version that also fits your application, Cypress version, and native dependencies. The sample’s Node version is an example, not a requirement for every project. Microsoft’s JavaScript pipeline guidance explains the Azure task context.

As an Amazon Associate I earn from qualifying purchases.

pool:
  vmImage: ubuntu-latest

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

- script: npm ci
  displayName: Install dependencies

- script: mkdir -p results
  displayName: Create test results directory

- script: npm run start:ci & npx wait-on http://localhost:3000
  displayName: Start app and wait for readiness

- script: npx cypress run --reporter junit --reporter-options "mochaFile=results/test-output-[hash].xml"
  displayName: Run Cypress tests
  env:
    CYPRESS_BASE_URL: http://localhost:3000

- task: PublishTestResults@2
  displayName: Publish Cypress results
  condition: succeededOrFailed()
  inputs:
    testRunner: JUnit
    testResultsFiles: '**/results/test-output-*.xml'
    failTaskOnFailedTests: true

- task: PublishPipelineArtifact@1
  displayName: Publish Cypress diagnostics
  condition: succeededOrFailed()
  inputs:
    targetPath: cypress
    artifact: cypress-diagnostics
    publishLocation: pipeline

The example assumes wait-on is available to the project, npm run start:ci starts the app, and it serves the configured address on port 3000. Adapt the startup command and artifact path to your repository. Cypress’s Azure sample and installation workflow are documented at Cypress’s Azure DevOps guide.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare the project and agent

Choose a compatible Node version

Set NodeTool@0’s versionSpec to a version supported by your app’s engines, Cypress, and any native packages. The task selects Node for your build scripts; it is distinct from Node versions used internally by Azure task runners. Hosted agent images also determine the available operating system and browser environment. For a self-hosted agent, you are responsible for maintaining those system and browser dependencies.

Install from the lockfile

Commit package-lock.json and use npm ci so the build installs the versions recorded by the lockfile. Keep Cypress in the project’s devDependencies and invoke it through npx or an npm script rather than relying on a global installation. If packages come from a private npm feed, configure Azure’s documented npm authentication before the install step: npm authentication task.

Optionally verify the Cypress binary

A verification command can make installation failures easier to distinguish from test failures. Cypress’s sample calls a project verification script, but the script name is specific to that repository. If you have one, run it after installation, for example npm run cy:verify; otherwise omit the step. The standard CI flow is package installation followed by the Cypress CLI run command, not a special Azure extension.

Start the application before running tests

End-to-end tests need a reachable application. Starting a server in the background and immediately invoking Cypress can race: the browser may request the base URL before the app has begun listening. Use a readiness-aware tool such as wait-on, start-server-and-test, or an equivalent health check. The YAML waits for http://localhost:3000; change the URL to the real listening address and ensure the process remains alive for the test run. Cypress describes the startup race and readiness-gated approaches in its CI overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a preview or staging deployment, omit the local startup step and set CYPRESS_BASE_URL to that deployment’s URL. Cypress configuration values can be overridden with environment variables prefixed with CYPRESS_. Ensure the pipeline can reach the target environment and that the application is ready before testing.

Run Cypress and publish JUnit results

Execute tests non-interactively

Use npx cypress run for CI, or define a script such as "cy:run": "cypress run" and invoke npm run cy:run. Add options your project needs, such as a specific browser or spec selection. Cypress’s CI documentation covers the run command and CI configuration.

Generate one XML file per spec

Cypress includes a JUnit reporter. The example command writes files under results with a hash in each filename. A fixed filename can be overwritten when multiple spec files run, so use a unique pattern such as test-output-[hash].xml. Create the output directory before running tests, and make the Azure publish glob match the location and filenames your reporter actually produces. The Cypress reporter options are described in Cypress’s reporter documentation.

Publish even when tests fail

PublishTestResults@2 with condition: succeededOrFailed() lets Azure display test output when Cypress exits unsuccessfully as well as when it passes. The task’s testResultsFiles pattern must match the generated XML. Setting failTaskOnFailedTests: true ensures reported test failures keep the pipeline failed. See Microsoft’s Publish Test Results task reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep screenshots, videos, and reports for diagnosis

During cypress run, Cypress captures screenshots on test failure by default. Video recording is off by default; set video: true in Cypress configuration if the team needs recordings. Files on a hosted agent are temporary, so publish the relevant output as a pipeline artifact when you want to inspect it after the job. The sample publishes the cypress directory; adjust that path if your configuration stores screenshots or videos elsewhere. Cypress documents screenshot and video behavior in its screenshots and videos guide.

Cache dependencies without breaking reproducibility

Azure Pipelines caching can reduce time spent restoring packages. Cache npm’s shared cache rather than node_modules when using npm ci, because npm ci removes and recreates node_modules. Microsoft recommends a cache key incorporating the operating system and lockfile, with the npm cache stored in a workspace path. Cypress’s Azure sample also caches the Cypress binary directory; its exact filesystem paths may need adjustment for a different hosted image or self-hosted machine. Follow Azure Pipelines caching guidance and the Cypress Azure sample.

Choose hosted or self-hosted agents

Use a Microsoft-hosted agent when its operating system and browser images meet your needs and you prefer not to maintain build machines. A self-hosted agent can make sense when tests require custom system packages, private network access, or controlled persistent caches. That flexibility comes with responsibility for keeping the machine, browsers, and dependencies maintained. Neither choice is a universal Cypress requirement; base it on your environment and maintenance capacity.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Cypress Cloud only if its extra analysis helps

A basic Azure pipeline can run Cypress without recording to Cypress Cloud. Cloud is an optional service for teams that want capabilities such as recorded-run failure context and replay, screenshots, flaky-test analysis, analytics, and visibility into which machines ran tests in parallel. Compare those needs with Azure’s test summary and retained artifacts before adding another service. Current Cloud pricing is not established here, so check Cypress’s own service information before making a cost decision.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If you enable recording, keep the Cypress record key in Azure secret pipeline variables; do not commit it in YAML or expose it in logs. Cypress also recommends CI-provider credentials that expire with the job rather than personal access tokens for recorded source-control metadata. See Cypress Cloud project and recording documentation.

Or skip the browser setup

If your goal is a screenshot rather than an end-to-end test, ScreenshotNeo offers a one-request screenshot API and MCP server. For example, save a screenshot of a public page with cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for API options. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.

Troubleshoot common pipeline failures

Cypress cannot reach the application

  • Confirm the server command starts successfully and leaves the server process running.
  • Check that the readiness URL, Cypress base URL, hostname, and port match the application’s actual listening address.
  • Make sure the readiness check completes before the Cypress step and that the agent can reach the target network.

Dependency installation or Cypress binary fails

  • Check that the selected Node version fits the project, Cypress, and native dependencies.
  • Confirm the lockfile is committed and the install logs show successful dependency resolution.
  • Run the project’s Cypress verification script, if present, to separate binary installation issues from test failures.
  • For private packages, check npm feed authentication before npm ci.

Azure test summary is empty or incomplete

  • Inspect the agent output to confirm the JUnit XML files were actually created.
  • Compare their directory and filenames against testResultsFiles.
  • Use a distinct output filename per spec so later runs do not overwrite earlier files.
  • Confirm the publish task runs after Cypress even when the test command fails.

Failures are difficult to reproduce

  • Retain Cypress failure screenshots and enable video only if the extra diagnostic output is useful.
  • Publish the output directory as a pipeline artifact so it survives agent cleanup.
  • When a test targets a remote environment, verify that the pipeline uses the expected base URL and that the deployment is ready.

Caching does not improve the run

  • Cache the npm shared cache and, where appropriate, Cypress’s binary cache.
  • Do not expect a cached node_modules directory to survive npm ci; that command recreates it.
  • Check cache keys and paths against the operating system and the agent image in use.

Frequently Asked Questions

Does Cypress require a special Azure DevOps extension?

No. The usual CI setup installs the project dependencies and runs the Cypress CLI; Azure YAML orchestrates the job and tasks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do I need Cypress Cloud to run Cypress in Azure Pipelines?

No. Cloud recording is optional; a pipeline can run tests with npx cypress run without it.

Why use a hash in the JUnit filename?

A unique filename keeps output from one spec from overwriting another when Cypress runs multiple specs.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.