Fix formatting in Command Log test results.#5619
Conversation
|
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
|
Let's get some eyes on this and get this out in |
|
We'll need actual assertions on the output during the tests that have been added. Right now there's no way for them to fail |
| it('preserves quotation marks in empty string', function () { | ||
| try { | ||
| expect(42).to.eq('') | ||
| } catch (error) {} /* eslint-disable-line no-empty */ | ||
| }) | ||
|
|
||
| it('preserves quotation marks if escaped', function () { | ||
| expect('\'cypress\'').to.eq('\'cypress\'') | ||
| }) | ||
|
|
||
| it('removes quotation marks in DOM elements', function () { | ||
| cy.get('body').should('contain', 'div') | ||
| }) | ||
|
|
||
| it('removes quotation marks in strings', function () { | ||
| expect('cypress').to.eq('cypress') | ||
| }) | ||
|
|
||
| it('removes quotation marks in objects', function () { | ||
| expect({ foo: 'bar' }).to.deep.eq({ foo: 'bar' }) | ||
| }) | ||
|
|
||
| it('formats keys properly for "have.all.keys"', function () { | ||
| const person = { | ||
| name: 'Joe', | ||
| age: 20, | ||
| } | ||
|
|
||
| expect(person).to.have.all.keys('name', 'age') | ||
| }) | ||
| }) |
There was a problem hiding this comment.
would these have failed before the src changes? We should add assertions on the log output to turn these into valid tests
There was a problem hiding this comment.
Agreed. We need tests that actually verify this behavior. It might be worthwhile to move out and expose the removeOrKeepSingleQuotesBetweenStars and replaceArgMessages so they can be tested unit-style.
There was a problem hiding this comment.
I've checked the tests in assertions_spec.js and mimicked the tests it uses to validate message fixes I've done.
| age: 20, | ||
| } | ||
|
|
||
| expect(person).to.have.all.keys('name', 'age') |
There was a problem hiding this comment.
I've added tests for "boldness". If the tests failed and something like that happens, please tell me.
p.s. I doubt it has something to do with the font setting. When I look at them closely, name and age are a little bit bolder than other texts, I guess. (When we compare a in name of the object and a in have keys. We can see that the former a is a bit darker than the latter a.
It would be great if we have other messages to compare the boldness.
|
| it('preserves quotation marks if escaped', (done) => { | ||
| expectMarkdown( | ||
| () => expect(`\'cypress\'`).to.eq(`\'cypress\'`), | ||
| // ****'cypress'**** -> ** for emphasizing result string + ** for emphasizing the entire result. |
There was a problem hiding this comment.
thanks for adding this comment 🙏
There was a problem hiding this comment.
Actually, when I saw this, I was too wondering why this happened.
And thought many developers who will read this code later would be confused when they saw ****. That's why I've added this comment.
|
Awesome job @sainthkh! |

I fixed these 3 issues together because implementing one logic can affect other issues.
User facing changelog
Additional details
Why was this change necessary:
Issue #25
Issue #753
Issue #1360
What is affected by this change?
Not much. I added a few tests to show this case clearly.
Any implementation details to explain?
Not much. Just fixed some regexes.
How has the user experience changed?
Before: above.
After:
PR Tasks
Has a PR for user-facing changes been opened incypress-documentation?Have API changes been updated in thetype definitions?Have new configuration options been added to thecypress.schema.json?