PHPackages                             dillingham/nova-assertions - 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. dillingham/nova-assertions

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

dillingham/nova-assertions
==========================

Nova api testing requests &amp; assertions

1.2.0(5y ago)78274.2k↓53.5%15[8 issues](https://github.com/dillingham/nova-assertions/issues)[2 PRs](https://github.com/dillingham/nova-assertions/pulls)MITPHP

Since Aug 17Pushed 2y ago3 watchersCompare

[ Source](https://github.com/dillingham/nova-assertions)[ Packagist](https://packagist.org/packages/dillingham/nova-assertions)[ RSS](/packages/dillingham-nova-assertions/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (9)DependenciesVersions (10)Used By (0)

Nova Assertions
===============

[](#nova-assertions)

[![Latest Version on Github](https://camo.githubusercontent.com/564722dadf099df4e53812c8713e84963d9425b16bcf574301512379943d5919/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64696c6c696e6768616d2f6e6f76612d617373657274696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dillingham/nova-assertions)[![Total Downloads](https://camo.githubusercontent.com/c8a562ac1c20cc4ba773fd9a20414750581295606d6dd2512d464d4863a608fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64696c6c696e6768616d2f6e6f76612d617373657274696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dillingham/nova-assertions) [![Twitter Follow](https://camo.githubusercontent.com/4d611bda2f6e8730161339d887cbe17afe7f160bfde2eeb1baaf7cc40dd65071/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f696d5f627269616e5f643f636f6c6f723d253233316461316631266c6162656c3d54776974746572266c6f676f3d253233316461316631266c6f676f436f6c6f723d253233316461316631267374796c653d666c61742d737175617265)](https://twitter.com/im_brian_d)

Nova requests &amp; assertions for Laravel tests - [View examples](https://github.com/dillingham/nova-assertions/tree/master/examples)

[![testing tdd laravel nova](https://user-images.githubusercontent.com/29180903/63385407-e3f7d680-c36e-11e9-96f8-6ebbe48bd62b.png)](https://user-images.githubusercontent.com/29180903/63385407-e3f7d680-c36e-11e9-96f8-6ebbe48bd62b.png)

Assert: [Policies](https://github.com/dillingham/nova-assertions#assert-policies) | [Cards](https://github.com/dillingham/nova-assertions#assert-cards) | [Actions](https://github.com/dillingham/nova-assertions#assert-actions) | [Filters](https://github.com/dillingham/nova-assertions#assert-filters) | [Lenses](https://github.com/dillingham/nova-assertions#assert-lenses) | [Resources](https://github.com/dillingham/nova-assertions#assert-resources) | [Fields](https://github.com/dillingham/nova-assertions#assert-fields) | [Relations](https://github.com/dillingham/nova-assertions#assert-relations)

---

### Installation

[](#installation)

```
composer require dillingham/nova-assertions --dev

```

Enable by adding the `NovaAssertions` to a test

```
use NovaTesting\NovaAssertions;

class UserTest extends TestCase
{
    use NovaAssertions;
}
```

---

### Authentication

[](#authentication)

Log in a user that **[has access to Nova](https://nova.laravel.com/docs/2.0/installation.html#authorizing-nova)**

```
$this->be(factory(User::class)->create());
```

### Nova Requests

[](#nova-requests)

Request using a resource's uriKey to perform assertions:

```
$response = $this->novaIndex('users');

$response = $this->novaDetail('users', $user->id);

$response = $this->novaCreate('users');

$response = $this->novaEdit('users', $user->id);

$response = $this->novaLens('users', Lens::class);
```

### Request Filters

[](#request-filters)

You may also pass filters &amp; their values to indexes &amp; lenses

```
$response = $this->novaIndex('users', [
    StatusFilter::class => 'active'
]);
```

```
$response = $this->novaLens('users', Lens::class, [
    StatusFilter::class => 'active'
]);
```

### Assert Http

[](#assert-http)

You can call **[http response methods](https://laravel.com/docs/5.8/http-tests#available-assertions)** as usual:

```
$response->assertOk();
```

### Assert Resources

[](#assert-resources)

```
$response->assertResourceCount(3);
```

```
$response->assertResources(function($resources) {
    return $resources->count() > 0;
});
```

### Assert Cards

[](#assert-cards)

```
$response->assertCardCount(5);
```

```
$response->assertCardsInclude(Card::class);
```

```
$response->assertCardsExclude(Card::class);
```

```
$response->assertCards(function($cards) {
    return $cards->count() > 0;
});
```

### Assert Actions

[](#assert-actions)

```
$response->assertActionCount(5);
```

```
$response->assertActionsInclude(Action::class);
```

```
$response->assertActionsExclude(Action::class);
```

```
$response->assertActions(function($actions) {
    return $actions->count() > 0;
});
```

### Assert Filters

[](#assert-filters)

```
$response->assertFilterCount(5);
```

```
$response->assertFiltersInclude(Filter::class);
```

```
$response->assertFiltersExclude(Filter::class);
```

```
$response->assertFilters(function($filters) {
    return $filters->count() > 0;
});
```

### Assert Lenses

[](#assert-lenses)

```
$response->assertLensCount(5);
```

```
$response->assertLensesInclude(Lens::class);
```

```
$response->assertLensesExclude(Lens::class);
```

```
$response->assertLenses(function($lenses) {
    return $lenses->count() > 0;
});
```

### Assert Fields

[](#assert-fields)

```
$response->assertFieldCount(5);
```

Assert a specific field exists

```
$response->assertFieldsInclude('id');
```

Assert a specific field contains a value

```
$response->assertFieldsInclude('id', $user->id);
```

Assert multiple fields exist

```
$response->assertFieldsInclude(['id', 'email']);
```

Assert multiple fields with specific values exist

```
$response->assertFieldsInclude(['id' => 1, 'email' => 'example']);
```

Assert multiple values for one field exist

```
$response->assertFieldsInclude('id', $users->pluck('id'));
```

Make assertions against a collection of fields

```
$response->assertFields(function($fields) {
    return $fields->count() > 0;
});
```

Also `exclude` works in all of these scenarios

```
$response->assertFieldsExclude(['id' => 1, 'email' => 'example']);
```

### Assert Relations

[](#assert-relations)

```
// App\Nova\Post
// BelongsTo::make('Category'),
```

```
$response = $this->novaCreate('posts');

$response->assertRelation('categories', function($categories) {
    //
});
```

```
// App\Nova\Category
// HasMany::make('Posts'),
```

```
$response = $this->novaDetail('categories');

$response->assertRelation('posts', function($posts) {
    //
});
```

### Assert Policies

[](#assert-policies)

Assert **[Nova's use of policies](https://nova.laravel.com/docs/2.0/resources/authorization.html#authorization)** &amp; the authed user:

```
$response->assertCanView();

$response->assertCanCreate();

$response->assertCanUpdate();

$response->assertCanDelete();

$response->assertCanForceDelete();

$response->assertCanRestore();
```

Also can assert `cannot` for each:

```
$response->assertCannotView();
```

---

Author
======

[](#author)

Hi 👋, Im Brian Dillingham, creator of this Nova package [and others](https://novapackages.com/collaborators/dillingham)

Hope you find it useful. Feel free to reach out with feedback.

Follow me on twitter: [@im\_brian\_d](https://twitter.com/im_brian_d)

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~58 days

Recently: every ~115 days

Total

9

Last Release

2047d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29180903?v=4)[Brian](/maintainers/dillingham)[@dillingham](https://github.com/dillingham)

---

Top Contributors

[![dillingham](https://avatars.githubusercontent.com/u/29180903?v=4)](https://github.com/dillingham "dillingham (12 commits)")[![khaled-dev](https://avatars.githubusercontent.com/u/14126335?v=4)](https://github.com/khaled-dev "khaled-dev (2 commits)")[![andresilvagomez](https://avatars.githubusercontent.com/u/2415015?v=4)](https://github.com/andresilvagomez "andresilvagomez (2 commits)")[![wfeller](https://avatars.githubusercontent.com/u/21337627?v=4)](https://github.com/wfeller "wfeller (2 commits)")[![knutle](https://avatars.githubusercontent.com/u/1419066?v=4)](https://github.com/knutle "knutle (1 commits)")[![asivaneswaran](https://avatars.githubusercontent.com/u/2759350?v=4)](https://github.com/asivaneswaran "asivaneswaran (1 commits)")[![stevelacey](https://avatars.githubusercontent.com/u/289531?v=4)](https://github.com/stevelacey "stevelacey (1 commits)")

---

Tags

laravellaravel-novatesting

### Embed Badge

![Health badge](/badges/dillingham-nova-assertions/health.svg)

```
[![Health](https://phpackages.com/badges/dillingham-nova-assertions/health.svg)](https://phpackages.com/packages/dillingham-nova-assertions)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M361](/packages/dms-phpunit-arraysubset-asserts)[gong023/assert_chain

enable you to use phpunit assert with method chain

1478.9k3](/packages/gong023-assert-chain)

PHPackages © 2026

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