cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Laravel route "login" does not exist.

Open troccoli opened this issue 3 years ago • 6 comments

I'm using Cypress 10, which may be relevant, and version 2.2.1 of this package.

I have a simple test to check the login form works

describe('Login', function () {
    it('redirects to the home page once logged in', function () {
        cy.visit({route: 'login'})
            .get('#email').type('[email protected]')
            .get('#password').type('password')
            .get('[type="submit"]').click()
            .url().should('eq', Cypress.config().baseUrl + '/');
    });
});

The test passes, but I get the message Laravel route "login" does not exist.

Screenshot 2022-06-04 at 15 31 05

It clearly exists so I'm not sure what is that about. Besides, the message in an assertion and it's green, which indicates it's not an error (which is correct).

Could it be that maybe the package is trying to assert the route exist rather than it doesn't?

troccoli avatar Jun 04 '22 14:06 troccoli

facing the same issue

rcrespo9 avatar Jun 14 '22 16:06 rcrespo9

@troccoli I have the same issue but if I add cy.refreshRoutes() to the top of the test then its happy.

i-bajrai avatar Jun 23 '22 07:06 i-bajrai

I do call cy.refreshRoutes() in the before() method.

troccoli avatar Jun 23 '22 08:06 troccoli

It looks like the route handler (in laravel-routes.js) is correctly validating that the route exists, but the "error message" is stating the opposite of what it should state.

I think the feedback Chai and Cypress are giving, should be what we're trying to assert, not what we want to know if the assertion fails. E.g. Assert the route exists, then the message should be "Laravel route "login" should exist"

Joucke avatar Oct 31 '22 11:10 Joucke

Placing cy.refreshRoutes() in before() does not fix this for me

Thinkro avatar Dec 02 '22 09:12 Thinkro

I'm ignoring these messages for now. It's only the representation in the Cypress UI that is a bit misleading. The message doesn't appear when running headless mode unless the route actually doesn't exist.

Slund avatar Dec 02 '22 09:12 Slund