Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
reinink opened this issue Jun 3, 2021 · 1 comment
Open

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

reinink opened this issue Jun 3, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@reinink
Copy link
Member

reinink commented Jun 3, 2021

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');
}
@oberocks
Copy link

@reinink Hi there and thank you so much for your work with this package, Jonathan! 💪 😎 🚀

I've only just started (this week) with wrapping my head around the architecture and architecture possibilities with SSR/Inertia. So please excuse my n00bness.

Otherwise, I just wanted to mention that your config idea here - is awesome and ideal (as you already know lol).

Additionally, re: your second idea here - is also super interesting and if I'm picking up what you're putting down... just spitballing here... but in theory couldn't we actually do a proper automated html validation check test with functionality like that - essentially pushing the node rendered markup back into either PHP/JS' hands for a w3c-based valid html/css check script to run on that returned markup?

If so, both of these would be insanely awesome additions to your already impressive functionalities, so if there's any way I can help, please let me know!

PS - there may very well already be ways to automate HTML validity checks via Laravel/PHP that I'm unaware of, as well. But I quite like the idea of working with a stack that let's me use PHP or Laravel or even JS to automate such tasks. That flexibility would open up lots of opportunities from a full-stack web design system POV, you know?

@jessarcher jessarcher added the enhancement New feature or request label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: New 📑
Development

No branches or pull requests

3 participants