PHPackages                             thetechyhub/cypress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. thetechyhub/cypress

ActiveLibrary[Framework](/categories/framework)

thetechyhub/cypress
===================

Laravel Cypress Boilerplate

1.0.2(5y ago)0103MITPHPPHP ^7.2.5

Since Aug 31Pushed 5y ago2 watchersCompare

[ Source](https://github.com/thetechyhub/cypress)[ Packagist](https://packagist.org/packages/thetechyhub/cypress)[ Docs](https://github.com/thetechyhub/cypress)[ RSS](/packages/thetechyhub-cypress/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Laravel + Cypress Integration
=============================

[](#laravel--cypress-integration)

> This package is a clone of [laracasts/cypress](https://github.com/laracasts/cypress) to support lower versions of php 7.2.5 or higher

This package provides the necessary boilerplate to quickly begin testing your Laravel applications using Cypress.

[![](https://user-images.githubusercontent.com/183223/89684657-e2e5ef00-d8c8-11ea-825c-ed5b5acc37a4.png)](https://user-images.githubusercontent.com/183223/89684657-e2e5ef00-d8c8-11ea-825c-ed5b5acc37a4.png)

Installation
------------

[](#installation)

Begin by installing the package as a Composer development-only dependency.

```
composer require thetechyhub/cypress --dev
```

If you haven't yet pulled in Cypress through npm, that's your next step:

```
npm install cypress --save-dev && npx cypress open
```

Next, generate the necessary Laravel Cypress boilerplate:

```
php artisan cypress:boilerplate
```

The final step is one you'll perform regardless of whether you use this package or not. Update your `cypress.json` file with the `baseUrl` of your application.

```
{
  "baseUrl": "http://my-app.test"
}
```

When making requests in your Cypress tests, this `baseUrl` will be prepended to any relative URL you provide.

```
cy.visit('/foo'); // http://my-app.test/foo
```

Environment Handling
--------------------

[](#environment-handling)

After running the `php artisan cypress:boilerplate` command, you'll now have a `.env.cypress`file in your project root. To get you started, this file is a duplicate of `.env`. Feel free to update it as needed to prepare your application for your Cypress tests.

Likely, you'll want to use a special database to ensure that your Cypress acceptance tests are isolated from your local database.

```
DB_CONNECTION=mysql
DB_DATABASE=cypress

```

When running your Cypress tests, this package will automatically back up your primary `.env` file, and swap it out with `env.cypress`. Once complete, of course the environment files will be reset to how they originally were.

> All Cypress tests run according to the environment specified in `.env.cypress`.

Usage
-----

[](#usage)

This package will add a variety of commands to your Cypress workflow to make for a more familiar Laravel testing environment.

We allow for this by exposing a handful of Cypress-specific endpoints in your application. Don't worry: these endpoints will **never** be accessible in production.

### cy.login()

[](#cylogin)

Create a new user record matching the optional attributes provided and set it as the authenticated user for the test.

```
test('authenticated users can see the dashboard', () => {
  cy.login({ name: 'John Doe' });

  cy.visit('/dashboard').contains('Welcome Back, John Doe!');
});
```

### cy.logout()

[](#cylogout)

Log out the currently authenticated user. Equivalent to `auth()->logout()`.

```
test('once a user logs out they cannot see the dashboard', () => {
  cy.login({ name: 'John Doe' });

  cy.visit('/dashboard').contains('Welcome Back, John Doe!');

  cy.logout();

  cy.visit('/dashboard').assertRedirect('/login');
});
```

### cy.create()

[](#cycreate)

Use Laravel factories to create and persist a new Eloquent record.

```
test('it shows blog posts', () => {
  cy.create('App\\Post', { title: 'My First Post' });

  cy.visit('/posts').contains('My First Post');
});
```

Note that the `cy.create()` call above is equivalent to:

```
factory('App\Post')->create(['title' => 'My First Post']);
```

You may optionally specify the number of records you require as the second argument. If provided, the attributes can be provided as the third argument.

```
test('it shows blog posts', () => {
  cy.create('App\\Post', 3);

  //
});
```

### cy.refreshDatabase()

[](#cyrefreshdatabase)

Trigger a `migrate:refresh` on your test database. Often, you'll apply this in a `beforeEach` call to ensure that, before each new test in the file, your database is freshly migrated and cleaned up.

```
beforeEach(() => {
  cy.refreshDatabase();
});

test('it does something', () => {
  // php artisan migrate:fresh has been
  // called at this point.
});
```

### cy.seed()

[](#cyseed)

Run all database seeders, or a single class, in the current Cypress environment.

```
test('it seeds the db', () => {
  cy.seed('PlansTableSeeder');
});
```

Assuming that `APP_ENV` in your `.env.cypress` file is set to "acceptance," the call above would be equivalent to:

```
php artisan db:seed --class=PlansTableSeeder --env=acceptance
```

### cy.artisan()

[](#cyartisan)

Trigger any Artisan command under the current environment for the Cypress test. Remember to proceed options with two dashes, as usual.

```
test('it can create posts through the command line', () => {
  cy.artisan('post:make', {
    '--title': 'My First Post',
  });

  cy.visit('/posts').contains('My First Post');
});
```

This call is equivalent to:

```
php artisan post:make --title="My First Post"
```

### cy.php()

[](#cyphp)

While not exactly in the spirit of acceptance testing, this command will allow you to trigger and evaluate arbitrary PHP.

```
test('it can evaluate PHP', () => {
    cy.php(`
        App\\Plan::first();
    `).then(plan => {
        expect(plan.name).to.equal('Monthly');
    });
});
```

Be thoughtful when you reach for this command, but it might prove useful in instances where it's vital that you verify the state of the application or database in response to a certain action. It could also be used for setting up the "world" for your test. That said, a targeted database seeder - using `cy.seed()` - will typically be the better approach.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Jeffrey Way](https://twitter.com/jeffrey_way)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

2076d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/98107c8a99ef0470b55b939da052e252ed1bc282d76bff273a3900676fa86a59?d=identicon)[thetechyhub](/maintainers/thetechyhub)

---

Top Contributors

[![JeffreyWay](https://avatars.githubusercontent.com/u/183223?v=4)](https://github.com/JeffreyWay "JeffreyWay (39 commits)")[![aimensasi](https://avatars.githubusercontent.com/u/13252355?v=4)](https://github.com/aimensasi "aimensasi (10 commits)")

---

Tags

laracastscypress

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thetechyhub-cypress/health.svg)

```
[![Health](https://phpackages.com/badges/thetechyhub-cypress/health.svg)](https://phpackages.com/packages/thetechyhub-cypress)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M669](/packages/laravel-socialite)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k84.2M223](/packages/laravel-horizon)[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M594](/packages/laravel-ui)[laravel/jetstream

Tailwind scaffolding for the Laravel framework.

4.1k19.8M136](/packages/laravel-jetstream)[stancl/tenancy

Automatic multi-tenancy for your Laravel application.

4.3k6.6M40](/packages/stancl-tenancy)[laracasts/cypress

Laravel Cypress Boilerplate

6273.2M4](/packages/laracasts-cypress)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
