Cypress commands and utilities for Custom Applications.
This package extends Cypress'
Define the task in the plugins file:
The configuration has changed for Cypress version >=
10.0.0. See the migration guide.
Define the task in the
Extend the Cypress commands:
This command performs the user login to the Merchant Center. It automatically detects whether the application is running on localhost or production and chooses the appropriate login mechanism.
- When the application runs locally, the same mechanism used in the
- When the application runs on production, a normal login flow is used where the user enters the credentials into the login form.
Available options are:
entryPointUriPath(required): The application entry point URI path is used to identify the correct application config.
dotfiles(optional): A list of dotenv files to load when the
custom-application-config.jsonis loaded (in case you're using an environment placeholder). By default the following dotenv files are loaded:
.env.local. You can also define the values using paths relative to the application folder.
initialRoute(optional): The route to open after login. If not defined, make sure to call
projectKey(optional): The project key to access the user session. The session token is valid for one project key at a time. Defaults to
onBeforeLoad(optional): The function to call before the page has loaded all of its resources. Use this as a chance to interact, for example, with the browser storage.
login(optional): An object with the user login credentials
password. If not provided, the
Cypress.env('LOGIN_EMAIL') || Cypress.env('LOGIN_USER')and the
disableCacheAcrossSpecs(optional): Turn off caching the session across specs. This is only relevant for Cypress version >=
The command also requires loading the
custom-application-config.json (automatically done via the Cypress task), so it may need to load environment variables in case the application config uses environment placeholders.
.env.local files are loaded by default from the application folder. You can pass a
dotfiles option to provide a list of names/paths relative to the application folder in case the files in the project have a different name/location.
Ensure that the following environment variables are available if the related options aren't provided explicitly:
The login command attempts to use the cy.session command, which caches and restores the user session between test runs.
This ultimately results in subsequent tests running much faster (by restoring the previous session) and making the test behave as if the user is authenticated.
cy.session command is enabled by default in Cypress v12. If you are using older versions make sure to have the option
experimentalSessionAndOrigin turned on (in your Cypress config).
This command is deprecated. We recommend using the more generic
cy.loginToMerchantCenter command as it automatically detects which login mechanism to use.