inertia-server provides testing utilities that work with your test setup. You can use the utilities for response parsing
and assertions, or delegate the latter part to your test framework.
Getting Started
There two functions used for testing:inertia function accepts a Response object, a HTML string or a Inertia page object and returns assertion utils.
If you are going to chain requests, for exmaple to load deferred props, inertia function takes an option object as
a second argument that contains the fetch function. You will have to provide it to instruct the assertion utils,
how to communicate with your app.
inertia-server will try to infer your server address from
the response you give it, otherwise it will throw an error.
You can also use the createAppHelper function to create a inertia function that will be bound to your app,
so there is no need to pass the fetch function every time.
Assertions
inertia-server comes with a set of basic assertions to test your page. If they are not enough for you, see the tap helper.
All assertions support dot notation for nested properties, i.e.
user.profile.name is the same as user['profile']['name'].Checking Props
Usehas() to assert that a prop exists:
has compares values deeply, but it’s a strict equality check. It will fail if the value is not exactly the same.Missing Props
To assert that a prop does not exist, use themissing method.
Flash and Errors
Flash messages and errors are just props, so you can assert them usinghas() and missing():
Page Metadata
Assert component name, URL, or version:Custom Assertions
Usetap() to run custom assertions with direct access to the page object. If you don’t want to use package specific assertions, you can use this method to run your own.