PHPackages                             romegasoftware/nova-test-suite - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. romegasoftware/nova-test-suite

ActivePackage[Testing &amp; Quality](/categories/testing)

romegasoftware/nova-test-suite
==============================

Library to help testing laravel nova resources faster

v3.0.0(1y ago)44.3kMITPHPPHP \*

Since Nov 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/romegasoftware/NovaTestSuite)[ Packagist](https://packagist.org/packages/romegasoftware/nova-test-suite)[ RSS](/packages/romegasoftware-nova-test-suite/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (27)Used By (0)

Nova Test Suite
===============

[](#nova-test-suite)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)![Travis](https://camo.githubusercontent.com/bce8ffa8f998f777fb9574a240d67cffce5270c1f1a4430c0556aa7a8855989e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f726f6d656761736f6674776172652f6e6f76612d746573742d73756974652e7376673f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/525a499355420da4c5ee8b5bd0915aaf67c0e932a6729c1a589328c4072fb191/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6d656761736f6674776172652f6e6f76612d746573742d73756974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romegasoftware/nova-test-suite)

Install
-------

[](#install)

`composer require romegasoftware/nova-test-suite --dev`

Usage
-----

[](#usage)

### Generate Resource Test Cases

[](#generate-resource-test-cases)

To get you started run `php artisan nova:test resource_name`. This will generate a Resource test and publish the `NovaResourceTestCase` if it was not already published.

First thing you will need to do after creating a resource tests is filling the `remapResource()` method. This method must map the nova fields names to the resource properties. It's also not needed to map each property of the resource, just the ones that change or are required to be diferent.

```
protected function remapResource($resource): array
{
    return [
        'location' => $resource->location_id,
        'theme' => $resource->theme_id,
    ];
}
```

The `$resource` parameter is a fresh generated model instance via `factory()` and therefore should hold any necessary values you need. The `$data` parameter is only filled if you call a nova request method with any data like `$this->storeResource(['name' => 'test'])`.

### requests

[](#requests)

**get resources**

```
// retrieve all available resources = viewing the index page
$this->getResources();

// retrieve a single resource = viewing a single resource in detail view
$resource = Resource::factory()->create();
$this->getResources($resource);
```

**store resources**

```
// resource data is generated behind the scenes with factory()->make()
$this->storeResource();

// also accepts model classes or arrays
$resource = Resource::factory()->make();
$this->storeResource($resource);
$this->storeResource(['name' => 'Vader']);
```

If a resource is stored successfully the returned status code of the response is `201`.

**update resources**

```
// resource data is generated behind the scenes with factory()->create()
$this->updateResource(['name' => 'Vader']);

// accepts model classes
$resource = Resource::factory()->create();
$resource->name = 'Vader';
$this->updateResource($resource);
```

**delete resources**

```
// resource data is generated behind the scenes with factory()->create()
$this->deleteResource();

// also accepts model classes, arrays or integers (ids)
$resource = Resource::factory()->create();
$this->deleteResource($resource);
$this->deleteResource(['id' => 12]);
$this->deleteResource(12);
```

### relationships

[](#relationships)

```
$this->assertHasManyRelationships([
    'product',
]);
$this->assertBelongsToRelationships([
    'user',
]);
```

`assertHasOneRelationships(array)``assertHasManyRelationships(array)``assertBelongsToRelationships(array)``assertBelongsToManyRelationships(array)``assertMorphToRelationships(array)``assertMorphOneRelationships(array)``assertMorphManyRelationships(array)`

### actions

[](#actions)

Use `assertHasActions()`

### lenses

[](#lenses)

use `assertHasLenses()`

### filters

[](#filters)

use `assertHasFilters()`

### Asserting a request has failed

[](#asserting-a-request-has-failed)

Since failed nova request return a redirect with status code `301` we introduced a new method `assertNovaFailed()` which checks for this without having to think about what status code a failed nova response returns.

```
$this->storeResource()
  ->assertNovaFailed();
```

### Testing required fields

[](#testing-required-fields)

To test if your Nova resource is setup correctly and check if all required fields are set as expected you can use the `setNullValuesOn([..])` method, which assignes every key you enter a `null` value for the next request.

```
$this->setNullValuesOn(['customer', 'number_of_participants'])
  ->storeResource()
  ->assertRequiredFields(['customer', 'number_of_participants']);
```

### Using the default user

[](#using-the-default-user)

By default each nova request method checks whether a request was already authenticated through `actingAs($user, 'api')`. If no user was provided to authenticate the request we will use the `getDefaultUser()` method to authenticate your request. If you want to be explicit about using the default user for a request you can use `$this->beDefaultUser()` which will return the current class, therefore it will also work with chaining e.g. `$this->beDefaultUser()->storeResource()`.

If you want to use your own user for every request you can override the `getDefaultUser()` method.

```
protected function getDefaultUser()
{
    return $this->yourOwnUser;
}
```

### Debugging failing requests

[](#debugging-failing-requests)

To debug more easily why your nova request is failing you can chain `assertSessionDoesntHaveErrors()` before you make any assertions about the status. This method will dump all session errors and the json response of the request.

```
$this->storeResource()
  ->assertSessionDoesntHaveErrors();
```

If you still can't figure out why you are receiving the status code of the response, try to get behind the reason of the response with `withoutNovaExceptionHandling()`. This method call will create a callback which calls the underlying `withoutExceptionHandling()` as soon as the Nova middleware runs. You can also chain the calls:

```
$this->withoutNovaExceptionHandling()
  ->storeResource();
```

Testing
-------

[](#testing)

Run the tests with:

```
vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Braden Keith](https://github.com/romegasoftware)
- [Krishan Koenig](https://github.com/Naoray)
- [Erik C. Forés](https://github.com/ConsoleTVs)
- [All Contributors](https://github.com/romegasoftware/NovaTestSuite/contributors)

Security
--------

[](#security)

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

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 65.9% 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 ~71 days

Recently: every ~327 days

Total

26

Last Release

584d ago

Major Versions

v0.8 → v1.02020-11-03

v1.2.0 → v2.0.02021-03-08

2.1.4 → v3.0.02024-10-09

PHP version history (2 changes)2.1.4PHP ^7.3|^8.0.2

v3.0.0PHP \*

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/219298?v=4)[Braden Keith](/maintainers/bradenkeith)[@bradenkeith](https://github.com/bradenkeith)

---

Top Contributors

[![Naoray](https://avatars.githubusercontent.com/u/10154100?v=4)](https://github.com/Naoray "Naoray (29 commits)")[![bradenkeith](https://avatars.githubusercontent.com/u/219298?v=4)](https://github.com/bradenkeith "bradenkeith (11 commits)")[![ConsoleTVs](https://avatars.githubusercontent.com/u/6124435?v=4)](https://github.com/ConsoleTVs "ConsoleTVs (4 commits)")

---

Tags

laravel

### Embed Badge

![Health badge](/badges/romegasoftware-nova-test-suite/health.svg)

```
[![Health](https://phpackages.com/badges/romegasoftware-nova-test-suite/health.svg)](https://phpackages.com/packages/romegasoftware-nova-test-suite)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[spatie/laravel-mail-preview

A mail driver to quickly preview mail

1.3k419.3k5](/packages/spatie-laravel-mail-preview)[mpociot/laravel-test-factory-helper

Generate Laravel test factories from your existing models

933635.2k2](/packages/mpociot-laravel-test-factory-helper)[thedoctor0/laravel-factory-generator

Automatically generate Laravel factories for your models.

214997.4k1](/packages/thedoctor0-laravel-factory-generator)[christophrumpel/missing-livewire-assertions

This package adds missing livewire test assertions.

149336.0k9](/packages/christophrumpel-missing-livewire-assertions)

PHPackages © 2026

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