Coder Social home page Coder Social logo

Comments (8)

mattharcourt avatar mattharcourt commented on July 19, 2024 3

I just ran into this myself...

Not sure why, but in the test environment (not in the browser) it appears that the Inertia Facade returns a different instance of the Inertia\ResponseFactory when calling Inertia::render() than was returned when Inertia::share() was called when the AppServiceProvider was registered. As a result, the ResponseFactory used by the render method didn't have any shared props.

I was able to solve when I changed the Inertia Facade to always return the same instance by binding the ResponseFactory class into the app container as a singleton in the Inertia\ServiceProvider register method.

This has been proposed to solve a similar issue (#73) by @rojtjo in PR #75

from inertia-laravel.

georgehanson avatar georgehanson commented on July 19, 2024 1

Ignore that, I've just noticed #51 :)

from inertia-laravel.

reinink avatar reinink commented on July 19, 2024

Have you reviewed the tests in the PingCRM app? See here. Might be helpful. In particular, see the test macros here.

from inertia-laravel.

chargefield avatar chargefield commented on July 19, 2024

I have copied those macros already :)

When i call $this->assertHasProp('auth') it doesn't exist. Even $this->assertHasProp('app.name')...

$this->original->getData() only outputs the data provided to the Inertia::render function. I'm not getting any of the shared data.

Only in my tests...

from inertia-laravel.

georgehanson avatar georgehanson commented on July 19, 2024

Just in addition to this, it might be useful to have those assertions on a trait which can be applied to a Laravel test suite - rather than having to create the macros yourself.

What do you think @reinink?

from inertia-laravel.

rakk7 avatar rakk7 commented on July 19, 2024

Yeah, same issue here..

When calling $this->assertHasProp('auth') it doesn't exist.. the response doesn't contain the shared data.

But when I open some URL in the browser the "auth" prop does exist!

from inertia-laravel.

Juhlinus avatar Juhlinus commented on July 19, 2024

Hello, @rakk7 !

Those methods does not exist outside of the PingCRM as of right now. If you want to use them then check out the macros:

https://github.com/inertiajs/pingcrm/blob/master/tests/TestCase.php#L18-L52

Or review my PR: #51

from inertia-laravel.

rakk7 avatar rakk7 commented on July 19, 2024

@Juhlinus

Yeah, I already have these methods. I am facing the same issue as @chargefield.

from inertia-laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.