Log as error message in the cypress command log #24615
-
With log it is possible to log a message to the cypress command log. This has a blue color and is for information. Is it also possible to log an error message? The use-case is this: I have added a command. But for this command to successfully execute the environment variables have to be set. I would like the task to pause when no environment variable has been set, and the refer to the docs: Cypress.Commands.add('login', () => {
if (!Cypress.env('SOME_API_URL')) {
// ideally this would be a red message instead of blue
cy.log('Can\'t login because not all necessary Cypress environment variables have been set.');
cy.log('Please check the readme in this project.');
cy.pause();
}
cy.request({
url: Cypress.env('SOME_API_URL'),
// left out for brevity
}).then(resp => {
// left out for brevity
cy.log('succesfully logged in.');
}).as('login');
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@StudioSpindle Just curious, but why not just throw an error? You'll need to make updates and restart the test to successfully run after the envs have been configured. |
Beta Was this translation helpful? Give feedback.
@StudioSpindle Just curious, but why not just throw an error? You'll need to make updates and restart the test to successfully run after the envs have been configured.