You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have a very simple test that keeps failing on my Gitlab Ci.
Here is the test:
describe('Login Test', () => {
it('should show error message when wrong password is entered', () => {
cy.visit('http://localhost:8080');
// press the login button
cy.get('[data-testid="login-button"]').click();
// Enter incorrect credentials on keycloak
cy.origin('https://<MY_AUTH_URL.dev', () => {
cy.get('#username').should('be.visible').type("testuser@gmail.com"); // Correct username
cy.get('#password').should('be.visible').type("wrongpassword"); // Incorrect password
cy.get("#kc-login").should("be.visible").click();
// Check that the error message is displayed
cy.get('#input-error').should('be.visible');
});
})
});
On my local runs, everything goes okay. But when I run this on my following Ci script:
build:
stage: build
script:
- npm ci
- npm run build
artifacts:
paths:
- dist
- .env
expire_in: 1 hour
test:
stage: test
image: cypress/included:cypress-13.16.1-node-22.12.0-chrome-131.0.6778.108-1-ff-133.0-edge-131.0.2903.70-1
dependencies:
- build
script:
# Step 1: Install Cypress and wait-on
- npm install wait-on --save-dev
- echo "Cypress version:"
- npx cypress --version
# Step 2: Start the application in the background
- npm run preview &
# Step 3: Wait for the application to be available
- npx wait-on http://localhost:8080
# Step 4: Run Cypress e2e tests
- npx cypress run --headless
it gives me the following error
1) Login Test
should show error message when wrong password is entered:
CypressError: Timed out retrying after 4000ms: The command was expected to run against origin `https://keycloak.promethist.dev/` but the application is at origin `http://localhost:8080/`.
This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.
Using cy.origin() to wrap the commands run on http://localhost:8080/ will likely fix this issue. cy.origin('http://localhost:8080'/, () => { <commands targeting http://localhost:8080/ go here> }) https://on.cypress.io/cy-visit-succeeded-but-commands-fail
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I have a very simple test that keeps failing on my Gitlab Ci.
Here is the test:
On my local runs, everything goes okay. But when I run this on my following Ci script:
it gives me the following error
Can someone help me figure this out?
Beta Was this translation helpful? Give feedback.
All reactions