3

When you do something like the following:

const someObject = { key: 1, anotherKey: 'test' } cy.log("Some object", someObject) 

It will be rendered in the Cypress UI as Some object, Object{2}

Is there a way to get this to print prettier?

I am on version 10.3.0 here is a result with my actual log message: enter image description here

Actual code:

 const loginInput = { userContext: "global_", email: finalEmail, password, verificationCode, }; cy.log("Authenticating via GraphQL with the following details", loginInput); 
1
  • How can my question be a duplicate of a question that is younger than mine? Lol Commented Jun 9, 2023 at 8:44

1 Answer 1

4

I ran the same code, and it is showing the key-value pairs in the log.

test runner screenshot

You can use the Javascript Method Object.entries() to loop over the key-value pair and log them one by one.

const someObject = { key: 1, anotherKey: 'test', anotherKey2: 'test2', } Object.entries(someObject).forEach(([key, value]) => { cy.log(key, value) }) 

Test runner 2

Sign up to request clarification or add additional context in comments.

9 Comments

What version are you using? I am on 10.3.0
I am using 10.4.0.
Ok, I will try and bump and see if that resolves it!
Nope, that didn't work for me... what browser were you using above?
I think you have to write the code you are actually trying because your screneshot and your code are different. This should work in 10.3.0 as well
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.