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.
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() })