'Using cy.log to print out Cypress environment variables
Goal: How can I print Cypress environment variables?
Code:
cy.log(Cypress.env()); // Error: Argument of type 'ObjectLike' is not assignable to parameter of type 'string'.ts(2345)
I understand I can't print it because cy.log() takes in a string and Cypress.env() is of type ObjectLike, but I'm not sure what other approach I can take to print it.
Solution 1:[1]
It's a typescript error, so you can type the parameter
cy.log(Cypress.env() as any)
or use this form .log(message: string, ...args: any[])
cy.log('env', Cypress.env())
or Cypress.log() with options (options.message is type any)
Cypress.log({ name: 'env', message: Cypress.env() })
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fody |
