Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cy.visitRoute() command. Update README #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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