You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/collections/pages/testing.md
+46-2Lines changed: 46 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,50 @@ class ExampleTest extends TestCase
85
85
}
86
86
```
87
87
88
+
### Update Scripts
89
+
90
+
To test an [update script](/addons/building-an-addon#update-scripts), import the `RunsUpdateScripts` trait and call `$this->runUpdateScript()` with your script class.
91
+
92
+
```php
93
+
use Statamic\Testing\Concerns\RunsUpdateScripts; // [tl! focus]
The `RunsUpdateScripts` trait is only available in Statamic v6.3.0 and above. You may need to bump your minimum supported version to use it.
111
+
:::
112
+
113
+
### Inertia.js
114
+
115
+
The Control Panel is powered by [Inertia.js](https://inertiajs.com), allowing Statamic to render pages as Vue components instead of traditional Blade views.
116
+
117
+
To assert an Inertia response, use the `->assertInertia()` macro:
118
+
119
+
```php
120
+
use Inertia\Testing\AssertableInertia as Assert;
121
+
122
+
$this
123
+
->get(cp_route('my-addon.index'))
124
+
->assertInertia(fn (Assert $page) => $page
125
+
->component('my-addon::Foo')
126
+
->has('message');
127
+
);
128
+
```
129
+
130
+
For more details, see the [Inertia.js testing documentation](https://inertiajs.com/docs/v2/advanced/testing).
131
+
88
132
## Running Tests
89
133
90
134
Once you've written some tests, you can run them using `phpunit`:
0 commit comments