algolia / vue-instantsearch

👀 Algolia components for building search UIs with Vue.js
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue
MIT License
854 stars 157 forks source link

Problem with test createServerRootMixin with Jest #1131

Closed kuzeofficial closed 2 years ago

kuzeofficial commented 2 years ago

Bug 🐞

What is the current behavior?

I have the following mixin CleanShot 2022-07-13 at 20 00 43

And the following text for mixin CleanShot 2022-07-13 at 20 04 51

The error when running the test is as follows CleanShot 2022-07-13 at 20 06 38

I am aware that it is not the SSR adaptation but I am using the createServerRootMixin because it globalizes the client, and does not reinstall it when reassembling the component, because I need two client instances each with a different API key.

What is the version you are using?

"vue-instantsearch": "4.4.0",

Haroenv commented 2 years ago

You're setting instantsearch to null instead of exposing it from the parent component, that's likely what's causing the error. For more detailed debugging, we should have a reproduction and also what you're trying to assert in the test

kuzeofficial commented 2 years ago

I don't think it's that since I tried to mock this property as a function, I also renamed my client in the data in case an overwrite was happening with the mixin and this didn't work either, the use case to test would be that the client is instantiated and that the data() method information is correctly assigned to the provide.$_ais_ssrInstantSearchInstance property of the context, I'll try to create a sandbox and share it.