-
Notifications
You must be signed in to change notification settings - Fork 10
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
localhost mode is not working in testing #34
Comments
Hi, please check the KB article: https://help.split.io/hc/en-us/articles/360047413111-How-to-use-Jest-to-test-React-SDK- Let me know if it helps. Thanks |
Thanks @chillaq But this configuration provides a way through enzyme, we are using react testing library. |
Hi, The React SDK only works on browser, it does not support server side, are you testing the code on browser side? |
Thanks @chillaq It runs the code in JSDOM, https://github.com/testing-library/react-testing-library |
Plain JS client is also not working with Jest. passing down following config:
getting splitClient like:
but its never calling callback function passed to
how to test ready state then ? |
Hi @ashoksudani , I have a suggestion from Engineering: Have you tried using craco? https://www.npmjs.com/package/@craco/craco#jest-api You might be able to use craco and configure that field without ejecting. Thanks |
hi @ashoksudani To let you know, we have released v1.2.4 of the React SDK, which includes an update to solve the issues you were facing when using Jest for unit testing. Now it is not required to configure Jest with neither the browser option or browser-resolve. In other words, you can now use the default Jest configuration, provided, for example, by create-react-app projects. No need to eject the project or use craco. Please, let us know if you need further details. |
I've been seeing the same thing using v1.2.4.
What I'm seeing is that the Here's a reproduction: Took me many hours to narrow it down to... hooks, or at least that's as far as I could go. Note that In my apps, I have a
|
it seems fixed in version 1.2.6 Please check #13 But not fully. When using storage type = 'localstorage' its giving
|
Hi @ashoksudani , We have considered your issue and we will address it in a coming release, probably for the end of next week. The current implementation of both React and JS SDKs overrides the 'storage' config param to the default 'MEMORY' type when using localhost mode. That is the reason why |
Hi @ashoksudani . Reaching you back. We have released JS SDK v10.16.0, and React SDK v1.3.0. Both are minor releases that let use localhost mode with LocalStorage storage type, in which case the SDK emits the SDK_READY_FROM_CACHE event (see line 30 of code snippet), and sets |
Thank you @EmilianoSanchez for fixing this issue. I will look forward to use this utility in our testing code for sure. 👍 |
I'm facing the same issue with the following code. const { isReady:} = useContext(SplitContext);
...
<div>
{!isReady ? (
<div >
<Skeleton />
<Skeleton />
<Skeleton />
</div>
) : (
<MyComponent />
)}
</div> Log:
MyComponent never gets to be rendered during the test (jsdom) because the hook never catches the |
Hi @felipeS , It has been a while since your comment, but I wanted to share that we have included a new doc section in our docs (Localhost mode) that includes unit test examples using different testing libraries, like Enzyme and React Testing Library. Tests show how to address the SDK behaviour regarding I will close the ticket for now. |
Hi,
We are using react-client in our app, while testing we used localhost mode as mentioned here https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode, but its always returning isReady property to false.
This is the splitprops we are getting, :
And config being passed is :
Any help regarding how to test react-client ?
Tried mocking http requests which is very difficult though as object being returned is very very complex to mock.
The text was updated successfully, but these errors were encountered: