From 24b4576c005964fff35faf30c08b2f44c1c670d6 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 14 Mar 2023 13:43:12 +0100 Subject: [PATCH] fix(tests): wait for request instead of fixed time --- cypress/e2e/user/login.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/user/login.spec.ts b/cypress/e2e/user/login.spec.ts index 97df3e17d..7ba127063 100644 --- a/cypress/e2e/user/login.spec.ts +++ b/cypress/e2e/user/login.spec.ts @@ -1,12 +1,14 @@ import {UserFactory} from '../../factories/user' const testAndAssertFailed = fixture => { + cy.intercept(Cypress.env('API_URL') + '/login*').as('login') + cy.visit('/login') cy.get('input[id=username]').type(fixture.username) cy.get('input[id=password]').type(fixture.password) cy.get('.button').contains('Login').click() - cy.wait(5000) // It can take waaaayy too long to log the user in + cy.wait('@login') cy.url().should('include', '/') cy.get('div.message.danger').contains('Wrong username or password.') }