Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: make content consistent in component tests that use faker #23080

Merged
merged 4 commits into from
Aug 3, 2022

Conversation

marktnoonan
Copy link
Contributor

  • Closes N/A

User facing changelog

N/A

Additional details

The content generated by faker was causing some visual regression failures as it changed in each test run. This PR adds a faker seed so that we now use consistent data when faker is called.

Steps to test

Load up the FileRow spec in the Launchpad project, rerun it a couple of times and you should see the same data each time. Comment out the faker.seed(1) and you should see that the data then changes each time you re-run the spec.

There are lots of other places we use faker, so I added the seed there as well, even though they are not currently covered by Percy snapshots that are flaky.

Being able to easily grab fake data when writing tests and have it change still seems very useful when developing components, so I'm not suggesting removing faker at this point -- but in CI I think we are going to be happier with stable values.

How has the user experience changed?

N/A

PR Tasks

  • Have tests been added/updated?
  • [na] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 3, 2022

Thanks for taking the time to open a PR!

@@ -135,11 +137,11 @@ describe('<Collapsible />', { viewportHeight: 450, viewportWidth: 350 }, () => {

const target = ({ open }) => (<h1 class={['text-xl', { 'pb-2': open }]}>Click here to open</h1>)

cy.mount(() => (<div class="mx-auto text-center w-300px my-4 border-1 p-4 rounded">
cy.mount(() => (<div class="rounded mx-auto border-1 my-4 text-center p-4 w-300px">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here, just class order getting updated on save.

@cypress
Copy link

cypress bot commented Aug 3, 2022



Test summary

37824 0 477 0Flakiness 11


Run details

Project cypress
Status Passed
Commit 08aa9bf
Started Aug 3, 2022 2:53 PM
Ended Aug 3, 2022 3:12 PM
Duration 18:28 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

cypress/e2e/commands/xhr.cy.js Flakiness
1 ... > logs request + response headers
2 ... > logs Method, Status, URL, and XHR
3 ... > logs response
4 ... > logs request + response headers
5 ... > logs Method, Status, URL, and XHR
This comment includes only the first 5 flaky tests. See all 11 flaky tests in the Cypress Dashboard.

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@@ -6,6 +6,8 @@ import faker from 'faker'
import { ref } from 'vue'
const fileMatchButtonSelector = '[data-cy=file-match-button]'

faker.seed(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth even using a faker module vs just removing the dependency and hard-coding a string? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue it's worth keeping it. I actually like the signal that "this is truly meaningless data, we only care that we get back what we put in" as opposed to a string that should be matched because the component is doing some calculations or something, where it's meaningful that the specific expected string is there.

But we aren't systematic in that kind of usage, so sure, it wouldn't be bad to talk about more.

@marktnoonan marktnoonan merged commit f73810d into develop Aug 3, 2022
@marktnoonan marktnoonan deleted the marktnoonan/percy-content-flake branch August 3, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants