Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,24 @@ test('it loads the team dashboard page using a named route', () => {
});
});
```
There is also a wrapper command available called `cy.visitRoute()` which can be used to simplify the boilerplate in the above examples.

```js
test('it loads the about page using a named route', () => {
cy.visitRoute('about');
});
```

and


```js
test('it loads the team dashboard page using a named route', () => {
cy.visitRoute('team.dashboard', {
parameters: { team: 1 }
});
});
```

Should you need to access the full list of routes for your application, use the `Cypress.Laravel.routes` property.

Expand Down
13 changes: 13 additions & 0 deletions src/stubs/support/laravel-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ Cypress.Commands.overwrite('visit', (originalFn, subject, options) => {
return originalFn(subject, options);
});

/**
* Visit the given route.
*
* @example cy.visitRoute('home');
* cy.visitRoute('team', { parameters: { team: 1 } });
*/
Cypress.Commands.add("visitRoute", (routeName, ...options) => {
return cy.visit({
route: routeName,
...options,
});
});

/**
* Create a new Eloquent factory.
*
Expand Down