handsome-cartoon-58565
01/08/2022, 2:04 PMhandsome-cartoon-58565
01/08/2022, 2:06 PMwonderful-match-15836
01/10/2022, 5:36 PMmagnificent-lamp-25446
01/10/2022, 5:36 PMjavascript
describe('TESTS', () => {
before(() => {
cy.intercept(
{ method: "GET", url: "URL1" },
{ fixture: "FIXTURE1" }
).as("ALIAS1");
cy.intercept(
{ method: "GET", url: "URL2" },
{ fixture: "FIXTURE2" }
).as("ALIAS2");
cy.visit("/PAGE");
});
describe("", () => {
it("FIRST BLOCK", () => {
const parametrosEsperados = {
...
};
cy.wait("@ALIAS1").then(({ request }) => {
cy.decodeQueryParams(request.url).should('deep.equal', parametrosEsperados);
})
})
it("ativo mensal terminais deve ser chamado com os parametros corretos", () => {
const parametrosEsperados = {
};
//This one fails.
cy.wait("@ALIAS2").then(({ request }) => {
cy.decodeQueryParams(request.url).should('deep.equal', parametrosEsperados);
})
})
})
});
wonderful-match-15836
01/10/2022, 6:02 PMit
blocks, you are running into the issue described here: https://docs.cypress.io/guides/core-concepts/variables-and-aliases#Aliases-are-reset-before-each-testhandsome-cartoon-58565
01/10/2022, 6:04 PMcypress run --headed
, not cypress open
command.magnificent-lamp-25446
01/10/2022, 6:06 PMwonderful-match-15836
01/10/2022, 6:47 PMwide-hospital-71307
01/10/2022, 9:32 PMbillowy-spoon-30011
01/11/2022, 10:06 AMancient-minister-75558
01/11/2022, 10:14 AMgray-flower-69892
01/11/2022, 2:24 PMancient-minister-75558
01/11/2022, 4:24 PMpurple-napkin-62735
01/11/2022, 4:37 PMadventurous-dream-20049
01/11/2022, 8:32 PM--openssl-legacy-provider
option should be passed to the plugins' child process when the system Node version is v17+.. You can see more in our docs here: https://docs.cypress.io/guides/references/changelog#9-2-1bumpy-yacht-37274
01/12/2022, 7:10 AMcy.exec
I have a strange errorhandsome-cartoon-58565
01/12/2022, 6:29 PMhandsome-cartoon-58565
01/12/2022, 6:44 PMbeforeEach
hook and i am aliasing them to wait
for them
js
// commands.js
Cypress.Commands.add('deleteEmails', () => {
return cy.request('DELETE', getEmailAPIURL(1));
});
Cypress.Commands.add('removeTestUsers', () => {
return cy.request({
method: 'DELETE',
url: '/api/users/delete',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
queryType: 'regex',
query: 'test user',
}),
});
});
// spec.js
beforeEach(() => {
cy.visit(ROUTES.ROOT);
cy.deleteEmails().as('deleteEmails');
cy.removeTestUsers().as('removeTestUsers');
cy.wait(['@deleteEmails', '@removeTestUsers']);
});
and i receive error
> "before each" hook for "should login to default user account":
> CypressError: cy.wait()
only accepts aliases for routes.
> The alias: deleteEmails
did not match a route.
what "route" it means - the alias name? there is no typo as far as i can see (also, i copy pasted the aliases names)
Without cy.wait
i have some race-conditions that i want to prevent. I have been using aliases and cy.wait
already in my code, which makes me more surprised, why it doesn't work hereuser
01/12/2022, 8:13 PMTimed out retrying after 5000ms: cy.wait()
?
ts
cy.intercept('POST', SIGN_UP).as('signUp')
cy.get('[data-test="sign-up-form"]').submit() cy.wait('@signUp').its('response.statusCode').should('eq', 200)
Fetch works correctlyhandsome-cartoon-58565
01/12/2022, 8:19 PMSIGN_UP
a correct value (url)?user
01/12/2022, 8:20 PMuser
01/12/2022, 8:21 PMuser
01/12/2022, 8:21 PMhandsome-cartoon-58565
01/12/2022, 8:22 PMuser
01/12/2022, 8:26 PMhandsome-cartoon-58565
01/12/2022, 8:55 PMcy.wait
with cy.get
(although, one wait
against two `get`s) as i found in the issue
https://github.com/cypress-io/cypress/issues/3827#issuecomment-502528398
> Using aliases with cy.request() is supported. Although, using cy.wait('@alias') does not work for request - since the cy.request() command itself will not resolve until it has a response.
I didn't find this explanation in the docs around the cy.request()
+ .as()
+ cy.get()
example, which i think would be helpful to not only have a working example with cy.request()
with .as()
, but to know that aliased cy.request()
doesn't work with cy.wait()
. IMO, what's more convenient in cy.wait()
(if it worked with cy.request()
) is it can be used with multiple aliases, which is not the case for cy.get()
.
https://docs.cypress.io/api/commands/request#Alias-the-request-using-asbumpy-yacht-37274
01/13/2022, 7:40 AMcy.exec
? My nodejs script?bumpy-yacht-37274
01/13/2022, 8:15 AMhandsome-cartoon-58565
01/13/2022, 10:28 AMcy.exec
handsome-cartoon-58565
01/13/2022, 10:28 AMconsole.clear()