-
Notifications
You must be signed in to change notification settings - Fork 612
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
[QUESTION] Can't properly setup async actions test on my app #48
Comments
Glad you like the project! I'm not sure you're getting the mocked store
I point this out because your directory layout shows something different with You should You could also Otherwise, nothing jumps out at me. Let me know what happens |
Thanks for the response. Actually, I'm getting a store, it's just an object with Can you tell how'd you come to such |
Jest is built on top of Jasmine and the Jest API docs reference PIT with this: https://www.npmjs.com/package/jasmine-pit. When writing my tests I had problems w/ the redux version of the store and so I modified it to get my tests working. I also add |
Thank you, I've gone through jasmine documentation, and that's why I've asked, as redux test example is using |
I'm running into the same issue. Something in the upgrade from react-native 0.17.1 to 0.18 is causing these tests to fail. If you take the base snowflake repo and update the versions the tests will fail. Here are the changed packages:
I also noticed that the current implementation of the store should also check that all of the expectedActions are emitted. That is why changing from pit to it gets the test passing. The store receives the first action but not the second. |
Seems like every time RN upgrades they break all the Jest testing... |
Well RN 0.19.0-rc1 is out (but the tests are still broken with it :) ) |
Snowflake was just fixed 6 days ago for RN 17! And I didn't figure it out - some one else did. This is frustrating. |
How do you set a breakpoint when testing? if I run Nevermind, setting --preload true in package.json let me set the breakpoint, but since the code was transpiled it's unreadable so the debugger seems useless. |
Set a break point in your source code before running |
@larubbio What steps do you use do to upgrade? I did |
For me I manually upgraded the versions in packages.json to the latest versions. I also had to move to npm3 because of an issue with fbjs (facebook/react-native#2985 (comment)) I then had to make some other small changes mostly the way redux was required since the /native entrypoint was dropped. |
@larubbio I just removed all the package.json My tests run fine now w/ RN 18.1 My dependencies:
Now to a I changed authActions-test.js to just this:
Then I run
Then, change the But now try this - notice the
That runs as:
But that's not right as there are other actions that ran! So change that
That fails, as it should!
The mock store can tell you when actions aren't run when they were expected to, but not tell you when more actions were run then expected actions. |
I get the following when running Xcode:
|
That error is why I had to move to npm3. It installs dependencies flat which removes the conflict. I think you might also be able to resolve it by directly installing fbjs. |
I updated my versions to match yours but I still get the timeout. I noticed the mock store will tell you if actions are raised that match the start of expectedActions, but not error out if more or fewer actions are raised. I was going to look at fixing that once I got my tests passing. |
That's not correct @larubbio - I documented that above quite clearly.
|
@larubbio I don't know anything about |
Are you sure about that? Looking at the code it's not clear to me how it would error if there were more actions than expected. It looks like the store just compares the list in order against the actions that are raised, but never checks that the count of raised actions matches the count of expected. |
I just meant version 3 of npm. RN doesn't require it, but the way it installs dependencies resolved the fbjs issue for me. |
@bartonhammond When I say "errors" I mean it doesn't fail the test when it should. It doesn't crash. |
@bartonhammond In a version still using RN 0.17.1 I changed the test to this:
and it passes even though the event ' {type: "GOODBYE"}' is never raised. The test should have failed. |
@larubbio that is right - the test should have failed. but if you moved that GOODBYE somewhere else in the sequence, it would fail |
It can tell when there are missing, but not when there are more, if the extra are appended to the original set |
I upgraded today to RN 0.18.1 |
Most all tests are passing now, see release notes: https://github.com/bartonhammond/snowflake/releases/tag/0.1.2-alpha |
Hi, I was looking at your project to get basic ideas for testing my RN app with
redux
,redux-thunk
and a set of async actions. Thanks for your great work I've been able to successfully test basic actions and components rendering, but can't make it work with promises.My app is RN 0.18 application with the following
package.json
config:My tests are placed at the top directory like so:
Store.js
file looks exactly like the one you've got here and myappState-test.js
file looks like:Where
actions/appState.js
looks following:However when I'm running my tests, only
START_FETCH_SMTH
has been dispatched and then I'm gettingtimeout: timed out after 5000 msec waiting for something to happen
.As for me this config looks exactly like the one in
snowflake
(tests from snowflake are running well) but they still doesn't work and I can't figure out why. Will appreciate if someone can help me as there isn't much information about RN testing, especially with Jest.If this is an inappropriate question/issue - feel free to close it.
Thanks.
The text was updated successfully, but these errors were encountered: