Experiments
If you'd like to try out what we're working on in Cypress, you can enable alpha features for your project by turning on the experimental features you'd like to try.
⚠️ The experimental features might change or ultimately be removed without making it into the core product. Our primary goal for experiments is to collect real-world feedback during their development.
Configuration
You can pass the Cypress configuration options below to enable or disable experiments. See our Configuration Guide on how to pass configuration to Cypress.
Option | Default | Description |
---|---|---|
experimentalFetchPolyfill | false | Automatically replaces window.fetch with a polyfill that Cypress can spy on and stub. Note: experimentalFetchPolyfill has been deprecated in Cypress 6.0.0 and will be removed in a future release. Consider using cy.intercept() to intercept fetch requests instead. |
experimentalInteractiveRunEvents | false | Allows listening to the before:run , after:run , before:spec , and after:spec events in the setupNodeEvents function during interactive mode. |
experimentalModifyObstructiveThirdPartyCode | false | Whether Cypress will search for and replace obstructive code in third party .js or .html files. NOTE: Setting this flag removes Subresource Integrity (SRI). |
experimentalSourceRewriting | false | Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm. See #5273 for details. |
experimentalWebKitSupport | false | Enable experimental support for running tests in WebKit. When set, installs of playwright-webkit will be detected and available in Cypress. See Launching Browsers for more information. |
Testing Type-Specific Experiments
You can provide configuration options for either E2E or Component Testing by
creating e2e
and component
objects inside your Cypress configuration.
End-to-End Testing
These experiments are available to be specified inside the e2e
configuration
object:
Option | Default | Description |
---|---|---|
experimentalStudio | false | Generate and save commands directly to your test suite by interacting with your app as an end user would. |
experimentalRunAllSpecs | false | Enables the "Run All Specs" UI feature, allowing the execution of multiple specs sequentially. |
experimentalOriginDependencies | false | Enables support for require /import within cy.origin . |
experimentalSkipDomainInjection | null | Disables injecting document.domain into text/html pages. |
Experimental Skip Domain Injection
Under the hood, Cypress
injects document.domain
into your test application. In some known cases, this causes issues with certain
sites. For example, Salesforce executes code in isolated window contexts. When
Cypress injects document.domain
, these window contexts become cross-origin and
fail to communicate. To work around this, the experimentalSkipDomainInjection
flag was introduced.
This flag disables injecting document.domain
inside Cypress, allowing Cypress
to test these exception cases. Only enable this flag if you are testing against
Salesforce or suspect you may have document.domain
issues. When enabled, this
option will require the use of cy.origin()
for all cross-origin navigations,
including subdomains. Please see our
Cross Origin Testing guide for more
details.
This flag can be enabled by passing an array of origin URLs or minimatch glob patterns. For example, here is how to enable this option for Salesforce and Google.
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
experimentalSkipDomainInjection: [
'*.salesforce.com',
'*.force.com',
'*.google.com',
]
}
})
import { defineConfig } from 'cypress'
export default defineConfig({
e2e: {
experimentalSkipDomainInjection: [
'*.salesforce.com',
'*.force.com',
'*.google.com',
]
}
})
The cypress.json
file has been replaced by cypress.config.js
or cypress.config.ts
in Cypress version 10.0.0. We recommend
that you update your configuration accordingly.
Please see the new configuration guide and the migration guide for more information.
{
"e2e": {
"experimentalSkipDomainInjection": [
"*.salesforce.com",
"*.force.com",
"*.google.com"
]
}
}
Component Testing
These experiments are available to be specified inside the component
configuration object:
Option | Default | Description |
---|---|---|
experimentalSingleTabRunMode | false | Run all specs in a single tab, instead of creating a new tab per spec. This can improve run mode performance, but can impact spec isolation and reliability on large test suites. |
History
Version | Changes |
---|---|
12.0.0 | Removed experimentalSessionAndOrigin and made it the default behavior. Added experimentalOriginDependencies . |
11.2.0 | Added experimentalRunAllSpecs . |
10.8.0 | Added experimentalWebKitSupport . |
10.6.0 | Added support for experimentalSingleTabRunMode . |
10.4.0 | Added support for experimentalModifyObstructiveThirdPartyCode . |
9.6.0 | Added support for experimentalSessionAndOrigin and removed experimentalSessionSupport . |
8.2.0 | Added support for experimentalSessionSupport . |
7.1.0 | Added support for experimentalInteractiveRunEvents . |
7.0.0 | Removed experimentalComponentTesting and made it the default behavior. |
6.7.0 | Removed experimentalRunEvents and made it the default behavior. |
6.3.0 | Added support for experimentalStudio . |
6.2.0 | Added support for experimentalRunEvents . |
6.0.0 | Removed experimentalNetworkStubbing and made it the default behavior when using cy.intercept(). |
6.0.0 | Deprecated experimentalFetchPolyfill . |
5.2.0 | Removed experimentalShadowDomSupport and made it the default behavior. |
5.1.0 | Added support for experimentalNetworkStubbing . |
5.0.0 | Removed experimentalGetCookiesSameSite and made it the default behavior. |
4.9.0 | Added support for experimentalFetchPolyfill . |
4.8.0 | Added support for experimentalShadowDomSupport . |
4.6.0 | Added support for experimentalSourceRewriting . |
4.5.0 | Added support for experimentalComponentTesting . |
4.3.0 | Added support for experimentalGetCookiesSameSite . |