close
The Wayback Machine - https://web.archive.org/web/20220311055059/https://github.com/cypress-io/cypress/issues/19317
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

cy.wait using array with one alias returns a single interception, not an array of iterceptions #19317

Open
veloware opened this issue Dec 9, 2021 · 1 comment

Comments

@veloware
Copy link

@veloware veloware commented Dec 9, 2021

Current behavior

According to the docs, https://docs.cypress.io/api/commands/wait#Aliases

and also the type definition for wait() -

wait(alias: string[], options?: Partial<WaitOptions>): Chainable<Interception[]>

a wait that accepts an array of aliases, should return an array of Interception

This doesnt seem to be the case when the array has one interception. The then callback receives a response with a single interception, so either this is incorrect, or the type definition is incorrect

e.g. having cy.wait([@myIterception]).then((res) => ...) currently yields res as a single interception object

Desired behavior

cy.wait([@myIterception]).then((res) => ...) should yield res as a an array of Interception objects, granted it would be an array of one Interception

Test code to reproduce

.

Cypress Version

8.4.1

Other

No response

@flotwig
Copy link
Member

@flotwig flotwig commented Feb 3, 2022

This is indeed a bug, the issue seems to be here:

// if we only asked to wait for one alias
// then return that, else return the array of xhr responses
const ret = responses.length === 1 ? responses[0] : responses

A PR with a fix and a test would be welcome.

@flotwig flotwig closed this Feb 3, 2022
@flotwig flotwig reopened this Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants