October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober 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 Test Salesforce with Cypress: Setup and Configuration

A practical Cypress setup for Salesforce-integrated apps, with guidance on test orgs, OAuth redirects, API checks, repeatable state, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To test a web application that integrates with Salesforce, run the app in a controlled test environment, set Cypress’s e2e.baseUrl to that app, and use a dedicated Salesforce Developer Edition org or development sandbox for authenticated API work. Use Cypress browser tests for user-visible journeys, cy.request() for API setup and checks, and cy.origin() when a test must interact with a second origin during OAuth or SSO. This recipe is for applications your team controls; it is not a universal way to test every Salesforce-hosted interface.

Choose the Salesforce surface you are testing

“Salesforce testing” can mean several different things, and the right Cypress setup depends on which one applies:

As an Amazon Associate I earn from qualifying purchases.

  • A custom web app that calls Salesforce APIs: run Cypress against your app and use authenticated API requests or controlled test endpoints to prepare and verify data.
  • An app that logs users in through Salesforce OAuth or SSO: test the redirect and login journey where that behavior matters, and handle commands on a second origin with cy.origin().
  • A Salesforce-hosted or platform-specific UI: check the tooling documented for that exact surface. Salesforce’s current Multi-Framework guide describes React/Angular unit-test tooling and Playwright E2E templates for its UI bundles, not Cypress. Salesforce Multi-Framework testing should not be generalized to all Salesforce applications.

Cypress’s own guidance is aimed at testing applications you build and control, not using Cypress as general-purpose automation for arbitrary external sites. See its E2E testing guidance.

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

Configure the application and Salesforce test org

  1. Start the application outside Cypress. Run the app server separately, then configure the Cypress E2E baseUrl to the local or controlled test deployment. Visit relative paths such as /login in tests. Cypress recommends starting the server separately rather than starting it inside a test script. See Cypress E2E testing.
  2. Use a development org. Use a Salesforce Developer Edition org or development sandbox for test API access. Salesforce’s REST API quick start documents a CLI-based flow that logs in to an org and provides an access token and instance URL. For a sandbox, use the sandbox login and resulting instance context.
  3. Keep the two URL roles separate. Cypress baseUrl is the web application Cypress visits. Salesforce REST requests go to the Salesforce org’s instance URL and require Salesforce authentication. Do not use the app’s base URL as though it were the Salesforce API host.
  4. Choose an OAuth flow for your app and org. The correct flow and client setup depend on application type and Salesforce org configuration. Salesforce’s OAuth documentation explains the available approaches; do not copy a client-app or flow setup without checking that it is permitted for your environment. Treat access and refresh tokens as secrets and keep credentials out of source control.

Use UI tests and API requests for different jobs

Use browser E2E tests for user-visible behavior

Use a small set of browser tests for behavior that only a browser journey can establish: whether login redirects correctly, whether a user can complete an important workflow, and whether the resulting interface communicates the expected outcome. If OAuth or SSO moves the browser to a different origin, wrap commands for that origin in cy.origin(). Cypress requires this for commands on a second origin in a test; it does not support cross-origin iframe automation. Details are in Cypress cross-origin testing.

Use cy.request() for setup, contracts, and persistence checks

cy.request() sends real HTTP requests and can inspect status, body, and headers. It is useful for preparing test data, checking API behavior, validating authorization cases, and confirming that a UI action persisted state on the server. It can use a relative URL when a suitable baseUrl is configured; for Salesforce requests, use the authenticated instance URL instead. See Cypress cy.request().

Salesforce REST requests must be authenticated. Salesforce states in its REST API Developer Guide that an access token obtained through authentication is required to send requests. For authenticated calls, supply the token as a secret and build the request URL from the instance URL returned for the test org. The precise Salesforce endpoint and payload depend on the API operation and org configuration; avoid hard-coding a production org or credentials into a Cypress test.

Make test state repeatable

  • Seed or reset data with supported test endpoints or Node-side cy.task() functions, rather than depending on leftover records or a sequence of fragile UI setup steps.
  • Keep a small number of tests that exercise the login UI when the login flow itself is under test. For the rest, a reusable login command and cy.session() can cache browser context; verify the cached session so stale authentication does not silently invalidate later tests. Cypress describes these patterns in its E2E testing guide.
  • Separate UI-created state from API- or task-seeded state according to the test’s purpose: create state through the interface when that workflow is what you are testing; seed it directly when the test concerns a later step.
  • Keep org data and configuration controlled. Tests against services or orgs your team does not control can be brittle, blocked, or affected by changes outside the test suite.

Decide where each check belongs

Decision Option Best fit
Authentication UI-driven OAuth or login redirect Validating the user-facing login and redirect journey.
Authentication Programmatic token-based setup Efficiently preparing authenticated state, provided the OAuth flow and client are supported by the org.
Test layer Browser E2E High-value user journeys and visible outcomes.
Test layer Direct API request with cy.request() API contracts, setup, permissions, and server-side persistence checks.
Environment Developer Edition org A dedicated development org for controlled test access and configuration.
Environment Development sandbox A test environment aligned with the team’s Salesforce setup and data policy.
State setup UI creates state When creating that state is part of the user workflow being tested.
State setup API or task seeds state When repeatable setup and focused checks matter more than testing state creation through the UI.

The Salesforce quick-start workflow supports a Developer Edition org or development sandbox; choose based on access, isolation, data policy, and org configuration rather than assuming one environment fits every team.

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

Troubleshoot common setup failures

Cypress visits the wrong site or cannot resolve a relative path

Check that the application server is running and that e2e.baseUrl points to the application under test. Use relative paths for app pages only after that is set. A Salesforce instance URL belongs in Salesforce API requests, not in the app’s baseUrl.

Salesforce API requests return an authentication error

Confirm that the request uses a valid access token for the selected org and the matching instance URL. Re-authenticate through the flow supported by the application and org, and ensure secrets are injected securely rather than committed in test files.

A redirect test fails after leaving the app’s origin

Commands interacting with the second origin need to be inside cy.origin(). If the desired behavior is inside a cross-origin iframe, Cypress does not support that automation; redesign the test around a supported integration boundary or another test strategy.

Tests pass alone but fail in a suite

Look for shared or stale org data, order-dependent setup, and expired cached browser sessions. Seed/reset state deterministically and validate the session cached by cy.session().

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

Tests are flaky against an external Salesforce surface

Make sure the test target is an app or org your team controls and is intended for automation. External pages, org policies, login requirements, and data changes can make a test unstable or prevent it from running.

Or skip the browser setup

If your immediate need is a screenshot of a page rather than an interactive Salesforce test, ScreenshotNeo is a website screenshot API and MCP server. A single request can return an image or PDF; its cleanup steps accept cookie banners and remove supported consent platforms, newsletter popups, and chat widgets before capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with response headers identifying the page verdict and billing status. Its MCP server exposes screenshot, page-info, and PDF tools for AI agents.

For a quick capture, use the API key from your account and replace the target URL as needed. See the ScreenshotNeo documentation.

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

The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for free.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Version and documentation notes

Cypress’s E2E documentation reported “Last updated on Sep 20, 2026” when checked on Oct 3, 2026 UTC. The cited Salesforce pages present current official guidance but do not state a publication or version date in the reviewed page content. OAuth flows, org policy, and tooling can change, so verify documentation against the Cypress version and Salesforce org configuration used by your project.

Frequently Asked Questions

Does Cypress have a Salesforce-specific plugin or one universal Salesforce test setup?

The documented approach depends on whether you are testing a custom app, an OAuth journey, or a particular Salesforce UI surface; Salesforce’s Multi-Framework UI bundle guidance documents different test tooling.

Can Cypress test Salesforce login redirects across domains?

Yes, for supported browser interactions, use `cy.origin()` for commands on the second origin. Cypress does not support cross-origin iframe automation.

Does setting Cypress `baseUrl` authenticate Salesforce API calls?

No. It identifies the web app Cypress visits. Salesforce REST requests need their own org instance URL and authenticated access token.

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.