Search code examples
testingautomationcypresstestcase

Cypress test running locally but skipping tests on github actions


I am using github actions to run my test cases it is working fine for 2-3 months but now it is skipping test on github actions. Tried adding wait but still nothing change. Can anyone Guide?

screenshot

I increase timeout but still skipping tests on github actions and giving this error

AssertionError: Timed out retrying after 10000ms: expected '/login' to match //dashboard$/


Solution

  • The first thing to note is that expected '/login' to match //dashboard$/ is a strong indication that the login failed.

    This can mean

    • the sever isn't running
    • the server isn't accessible from Github
    • the credentials have expired

    All these fit with the chronology you describe, the tests ran for 3 months and suddenly stop.

    I suggest you add a simple login-only test in a new repo and check the results for the above problems.

    The other thing to check is testIsolation, see Test Isolation as a Best Practice. This has been recently introduced, and the effect is to block credentials from carrying over from one test to another.

    There are two steps you can take:

    • temporarily turn off testIsolation in the config file
      const { defineConfig } = require('cypress')
      
      module.exports = defineConfig({
        e2e: {
          testIsolation: false,
        },
      })
      
    • add a cy.session() command around your login to make the login credentials persist across multiple test
      Cypress.Commands.add('loginWithUI', (username, password) => {
         cy.session(username, () => {
             cy.visit('/login')
             cy.get('#username-input').type(username)
             cy.get('#password-input').type(password)
             cy.get('#submit-button').click()
         })
      })