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.
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.
#1 Best Overall
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.
Rank #2
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.
Rank #3
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.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.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.
Recommended Free Tools
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.
Best Value
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_modulesdirectory to survivenpm 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.
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.
Quick Recap
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.




