Skip to content

Use SSR (server-side rendering) when testingΒ #273

@reinink

Description

@reinink

Now that SSR is possible with Inertia.js, it opens up some really interesting possibilities when it comes to testing an Inertia app. It now seems possible to have the tests actually generate the page HTML. This would allow us to check for any errors when rendering the page, and also run HTML ("see") assertions against the rendered HTML.

I'm creating this issue as a reminder to test this out when I have time. πŸ‘

Possible new config:

<?php

return [

    'ssr_mode' => env('INERTIA_SSR_MODE', false), // false, 'node', 'server', 'lambda'

];

Something to explore: Automatically removing the data-page attribute in testing mode, so that when you run an HTML assertion, it doesn’t match against the JSON encoded page object, but has to match against the actual rendered HTML. For example:

public function test_can_view_organizations()
{
    $this->actingAs($this->user)
        ->get('/organizations')
        ->assertSee('Apple')
        ->assertSee('Microsoft')
        ->assertDontSee('Yahoo');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    SSRhttps://inertiajs.com/server-side-renderingenhancementNew feature or request

    Type

    No type

    Projects

    Status

    New πŸ“‘

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions