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

Inertia fake / Inertia test helpers #105

Closed

Conversation

ChristianPavilonis
Copy link

I know @reinink has helpers coming, but I thought I'd make a PR if anyone wants to try out my fork and use some helpers now.

To try this fork out in an existing project update composer.json.

  "require": {
        .....
        "inertiajs/inertia-laravel": "dev-master", // change to dev-master
    },
    "repositories": [
        { // use forked repo.
            "type" : "vcs",
            "url" : "https://github.com/ChristianPavilonis/inertia-laravel.git"
        }
    ],

Run composer update

Usage:

In your test call the fake

Inertia::fake();

After that, you can use the assertions

Inertia::assertHasProps(['prop1', 'prop2]);

Inertia::assertHasProp('prop_name');

Inertia::assertPropsEqual($expectedProps);

Inertia::assertPropEquals($key, $expectedValue);

Inertia::assertComponentIs('ComponentName');

// You can also access the props
Inertia::getAllProps();

Inertia::getProp($key);

- Adds FakeResponseFactory with assertion functions
- Adds Inertia::fake() method to make facade use FakeResponseFactory
- updated .gitignore

Useage:
In a test use the Inerta::fake() method to start.
To assert call one of the methods on the Inerta facade. ie. Inerta::assertHasProp('prop_name');
…e the Response class.

This fixes some issues when asserting two models are equal or when evaluating a Closure.
@claudiodekker
Copy link
Member

Hi, thanks for creating this implementation and for sharing it with the Inertia community! It was a big inspiration for #124, which eventually turned into this package, which became the official testing helpers today as per #220. As such, I'll be closing this PR now.

Thanks again for contributing to Inertia! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants