Skip to content

Check if page components existΒ #272

@reinink

Description

@reinink

Currently the testing framework allows you to test if a page component actually exists. This behaviour is configured in the /config/inertia.php file:

'testing' => [
    'ensure_pages_exist' => true,
    'page_paths' => [
        resource_path('js/Pages'),
    ],
    'page_extensions' => ['js', 'svelte', 'ts', 'vue'],
],

However, it would be great to do this all the time. Currently if you try to visit a page that has a component that doesn't exist, an exception isn't thrown. All you get is a console error. In production, this is especially problematic, because the user has no idea something went wrong.

Is there any reason why we can't just do this automatically all the time? Yes, there would be an extremely minor performance hit to checking if the file exists. That practically doesn't seem like a real issue.

I'm thinking that we remove the testing property from the config, and just have these options available top level. The ensure_pages_exist property could accept an array of environments to run this check in:

'ensure_pages_exist' => ['local', 'production', 'testing'], // or set to "true" for always
'page_paths' => [
    resource_path('js/Pages'),
],
'page_extensions' => ['js', 'svelte', 'ts', 'vue'],

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Closed πŸšͺ

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions