Skip to content

Commit

Permalink
Improve hasDimensions command
Browse files Browse the repository at this point in the history
Seems to make it more stable, like it waits longer
  • Loading branch information
weotch committed Nov 17, 2023
1 parent 80718a7 commit ee82388
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
8 changes: 3 additions & 5 deletions packages/next/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
Cypress.Commands.add('hasDimensions',
{ prevSubject: true },
(subject, width, height) => {

expect(subject.width()).to.equal(width)
expect(subject.height()).to.equal(height)
return subject
cy.wrap(subject).invoke('width').should('equal', width)
cy.wrap(subject).invoke('height').should('equal', height)
})

// Check that a video is playing
Expand All @@ -28,7 +26,7 @@ declare global {
hasDimensions(
width: number,
height: number
): Chainable<JQueryWithSelector>
): Chainable<void>

isPlaying(): Chainable<void>
}
Expand Down
8 changes: 3 additions & 5 deletions packages/react/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
Cypress.Commands.add('hasDimensions',
{ prevSubject: true },
(subject, width, height) => {

expect(subject.width()).to.equal(width)
expect(subject.height()).to.equal(height)
return subject
cy.wrap(subject).invoke('width').should('equal', width)
cy.wrap(subject).invoke('height').should('equal', height)
})

// Check that a video is playing
Expand Down Expand Up @@ -44,7 +42,7 @@ declare global {
hasDimensions(
width: number,
height: number
): Chainable<JQueryWithSelector>
): Chainable<void>

isPlaying(): Chainable<void>
isPaused(): Chainable<void>
Expand Down
8 changes: 3 additions & 5 deletions packages/sanity-next/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
Cypress.Commands.add('hasDimensions',
{ prevSubject: true },
(subject, width, height) => {

expect(subject.width()).to.equal(width)
expect(subject.height()).to.equal(height)
return subject
cy.wrap(subject).invoke('width').should('equal', width)
cy.wrap(subject).invoke('height').should('equal', height)
})

// Check that a video is paused
Expand All @@ -28,7 +26,7 @@ declare global {
hasDimensions(
width: number,
height: number
): Chainable<JQueryWithSelector>
): Chainable<void>

isPlaying(): Chainable<void>
}
Expand Down

0 comments on commit ee82388

Please sign in to comment.