Back to Test Automation
2026-01-236 min read

Cypress Cloud allowlist URLs (Test Automation)

Learn Cypress Cloud allowlist URLs (Test Automation) step by step with clear examples and exercises.

Title: Test Automation Using Cypress Cloud: Secure Your Tests with Allowlisted URLs (Expanded)

Why This Matters

In the realm of test automation, security is paramount. Cypress Cloud's allowlist URLs feature helps secure your tests by controlling which URLs are accessed during test runs. This prevents unauthorized access and potential data breaches, making it an essential tool for any comprehensive test automation strategy. By implementing this feature, you can ensure that your tests only interact with approved domains, reducing the risk of security vulnerabilities.

Prerequisites

To follow this guide, you should have a basic understanding of:

  1. JavaScript programming language
  2. Test automation using Cypress
  3. Familiarity with Cypress Cloud (free trial available)
  • Install and set up Cypress for your project
  • Understand how to write tests using Cypress
  • Know how to run tests locally or on the Cypress Dashboard

Additional Prerequisites

  • Familiarity with package managers like npm or yarn
  • Basic understanding of configuring and managing JavaScript projects

Core Concept

Cypress Cloud allowslist URLs is a security feature that restricts test runs to only the specified URLs. This means that your tests will only interact with the approved domains, ensuring secure and controlled testing sessions.

To enable this feature, you need to configure Cypress to send the allowed URLs list during the test run. Here's how:

  1. Install the cypress-cloud-bunny plugin:
npm install cypress-cloud-bunny --save-dev
  1. In your Cypress configuration file (cypress.json), add the following:
{
"pluginsFile": "plugins/index.js",
"env": {
"CYPRESS_CLOUD_API_KEY": "<YOUR-API-KEY>",
"CYPRESS_ALLOWED_URLS": ["https://your-allowed-domain1.com/*", "https://your-allowed-domain2.com/*"]
}
}

Replace `` with your Cypress Cloud API key and add the URLs you want to allowlist.

Understanding the Allowed URLs List

The allowed URLs list is an array of strings that specifies the domains your tests can access during test runs. Each URL should be prefixed with https:// and may include wildcards (e.g., *.your-allowed-domain.com) to allowlist subdomains as well.

Subdomains and Wildcards

To allowlist subdomains, use the asterisk (*) wildcard before the domain name. For example:

"CYPRESS_ALLOWED_URLS": ["https://*.your-allowed-domain1.com/*", "https://*.your-allowed-domain2.com/*"]

This allows your tests to interact with any subdomain of your-allowed-domain1.com and your-allowed-domain2.com.

Worked Example

Let's create a simple test using Cypress that visits an allowed domain and verifies its title:

  1. Create a new spec file (e.g., allowlisted_domain.spec.js):
describe('Allowlisted Domain Test', () => {
it('Visits the allowlisted domain and checks its title', () => {
cy.visit('https://your-allowed-domain.com');
cy.title().should('include', 'Your Allowlisted Domain');
});
});
  1. Run the test using Cypress:
npx cypress run --record

The test will be sent to Cypress Cloud, and since we've allowed the specified domain, it should pass without issues.

Testing Multiple Allowed Domains

If you have multiple domains that your tests need to access, simply add them to the CYPRESS_ALLOWED_URLS environment variable in your Cypress configuration file (cypress.json).

Testing Subdomains

To test a subdomain of an allowed domain, make sure it follows the pattern you've defined in the allowed URLs list. For example:

describe('Subdomain Test', () => {
it('Visits a subdomain and checks its title', () => {
cy.visit('https://subdomain.your-allowed-domain.com');
cy.title().should('include', 'Your Subdomain');
});
});

Since subdomain.your-allowed-domain.com is included in the allowed URLs list, this test should pass without issues.

Common Mistakes

  1. Forgetting to add the cypress-cloud-bunny plugin: Make sure you install and include this plugin in your Cypress configuration file.
  2. Not specifying the correct API key: Double-check that you've entered the correct API key for your Cypress Cloud account.
  3. Incorrect URL pattern: Ensure that the URL pattern you provide is accurate and includes any necessary wildcards (e.g., https://your-allowed-domain.com/*).
  4. Running tests without the --record flag: Remember to pass the --record flag when running your tests, as this is how Cypress Cloud receives the test data.
  5. Not allowing enough domains or subdomains: If a test attempts to visit a URL not included in the allowed list, it will fail. Make sure you've added all necessary domains and subdomains to the allowed URLs list.
  6. Forgetting to update the allowed URLs list when adding new domains or subdomains to your application: Always ensure that your allowed URLs list is up-to-date with any changes in your application's domain structure.
  7. Incorrectly configuring the plugin: If you encounter issues after installing and configuring the cypress-cloud-bunny plugin, double-check that it's properly installed and configured according to the instructions provided.

Common Mistakes - Subheadings

1.1 Forgetting to update the allowed URLs list when adding new domains or subdomains to your application: Always ensure that your allowed URLs list is up-to-date with any changes in your application's domain structure.

1.2 Incorrectly configuring the plugin: If you encounter issues after installing and configuring the cypress-cloud-bunny plugin, double-check that it's properly installed and configured according to the instructions provided.

Practice Questions

  1. How can you allowlist multiple domains for your Cypress tests?
  • Add additional URL patterns to the CYPRESS_ALLOWED_URLS environment variable in your Cypress configuration file (cypress.json).
  1. What happens if a test attempts to visit a URL not included in the allowed list?
  • The test will fail, as it won't be able to interact with the unauthorized domain.
  1. Can you explain why it's important to secure test automation with features like Cypress Cloud's allowlist URLs?
  • It helps prevent unauthorized access and potential data breaches by restricting test runs to only the specified URLs, ensuring secure and controlled testing sessions.
  1. How can you allowlist subdomains as well as main domains for your tests using the allowed URLs list?
  • Use wildcards (e.g., *.your-allowed-domain.com) in the allowed URLs list to include both main domains and their respective subdomains.
  1. What is the purpose of the cypress-cloud-bunny plugin, and how does it help secure your tests?
  • The cypress-cloud-bunny plugin helps secure your tests by sending the allowed URLs list to Cypress Cloud during test runs, ensuring that your tests only interact with authorized domains.

FAQ

Q: How do I add more URLs to the allowed list for my tests?

A: Add additional URL patterns to the CYPRESS_ALLOWED_URLS environment variable in your Cypress configuration file (cypress.json).

Q: What happens if a test tries to visit a URL that's not included in the allowed list?

A: The test will fail, as it won't be able to interact with the unauthorized domain.

Q: Can I allowlist subdomains as well as main domains for my tests?

A: Yes, you can use wildcards (e.g., *.your-allowed-domain.com) to allowlist subdomains along with main domains.

Q: Can I specify a range of URLs or multiple ranges using the allowed URLs list?

A: No, the allowed URLs list expects individual URL patterns separated by commas. If you need to allowlist a range of URLs, consider creating separate entries for each subdomain or domain within that range.

Q: How can I ensure that my tests only interact with authorized domains using Cypress Cloud's allowlist URLs feature?

A: Configure your Cypress project to send the allowed URLs list during test runs by installing and configuring the cypress-cloud-bunny plugin.

Cypress Cloud allowlist URLs (Test Automation) | Test Automation | XQA Learn