Skip to content
Cypress plugin to test Laravel applications
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
types
.gitignore
.npmignore Implement create command and call setup on beforeEach hook Nov 15, 2019
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
webpack.config.js

README.md

Cypress Laravel

This Cypress plugin exposes commands to test Laravel applications. In order to use it, the Laravel app must have the laravel-cypress package installed.

You can read the following article to learn how this works: Testing Laravel Applications Using Cypress.

Installation

Install the package using npm:

npm install cypress-laravel --save-dev

And add the following at the beginning of your setup file at cypress/support/index.js:

import 'cypress-laravel';

// ...

Commands

This package includes typescript definitions, check them out to learn about the full API.

create

Create models using Laravel factories.

cy.create('App\\User', 3, { is_admin: false })
  .then(users => {
      // ...
  });

Quantity and attributes are optional arguments.

login / logout

Login or logout a user with Laravel's authentication. User id and authentication guard can be specified.

The user object will also be wrapped as user, so it can be retrieved later on calling cy.get('@user').

cy.login().then(user => {
    // ...
});

// ...

cy.logout();

Sandbox project

To see a working example, check out this project with a bare-bones Laravel application using this package with tests running on CI: laravel-cypress-sandbox.

You can’t perform that action at this time.