Vue.js - A custom command retrieves a subject before DOM updates, using a basic command correctly retrieves it _after_ #26594
Unanswered
lewishowles
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've written a number of custom commands. Some of them are fairly basic, and just make things a little easier for me to manage. For example, I have one called
findByData
, which just looks for an element by adata-test
attribute (cy.wrap(subject).get(`[data-test="${testSelector}"]`);
).I seem to have similar intermittent issues with a few of them, but the one I'm currently having trouble with at the moment is
shouldHaveCount
:I have a test that's changing the number of items shown in a list via a dropdown, and then counting that the correct number of items appears.
The last call there to check for 55 items fails, because it's still seeing 15 - which you can see in the playback. When the
get
happens fromfindByData
, there are 15 items. When thewrap
happens insideshouldHaveCount
, there are actually 55, but the length is reporting the original 15.What's confusing is two fold:
cy.findByData('data-table-row').should('have.length', 55);
that works every time.Is there anything obvious about how the commands are set up that would cause this? I've had this same issue with a few of my commands in the last few days. I thought it was because I converted a project to Vite (as I explain in https://stackoverflow.com/questions/76102745/cypress-vue-3-vite-custom-commands-invoked-before-page-re-renders) but it's now also happening in another project that hasn't yet been converted.
I'm using:
Beta Was this translation helpful? Give feedback.
All reactions