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

Showing where the error is with the expected actions assertion #7

Closed
subblue opened this issue Dec 24, 2015 · 9 comments
Closed

Showing where the error is with the expected actions assertion #7

subblue opened this issue Dec 24, 2015 · 9 comments

Comments

@subblue
Copy link
Contributor

subblue commented Dec 24, 2015

Firstly this library is proving to be very useful when testing my app, so many thanks!

One thing I have found is that if there is a mismatch with the expected actions in my test and the actual code then it can be tricky to find exactly where the problem is - typically the mocha test just times out because the done callback hasn't been triggered.

Is there a way to log the difference between expected and actual actions called?

@EvHaus
Copy link

EvHaus commented Dec 27, 2015

Definitely agree with this. It's very hard to know what went wrong and it's not obvious where I can place a console log to see what actually occurred. Would be great if there was some way to see what actions were fired vs what I was expecting to fire.

Here is a specific example. In my test I have:

const expectedActions = [
    {type: types.LOGOUT, message: 'test'}
];

const store = mockStore({AuthActions: []}, expectedActions, done);

Which was timing out. The issue is that my action actually fires with an error object key and not a message object key, and it was very difficult to track this down. The fix was:

const expectedActions = [
    {type: types.LOGOUT, message: 'test'}
];

const store = mockStore({AuthActions: []}, expectedActions, done);

If there was some way to know what actions were fired inside the mockStore, it would have been very easy to see what's wrong as you could visually see the expected vs the actual result.

@arnaudbenard
Copy link
Contributor

Which version are you both running?

@subblue
Copy link
Contributor Author

subblue commented Dec 29, 2015

v0.0.4

@arnaudbenard
Copy link
Contributor

Can you try v0.0.3, I think that v0.0.4 introduced that bug.

@chibicode
Copy link

@arnaudbenard need help on this?

@subblue
Copy link
Contributor Author

subblue commented Jan 5, 2016

Interesting, switching back to v0.0.3 I do now see the diff with the expected actions as hoped. However with 0.0.3, another test that involves actions triggered after an error has been caught in a promise (part of an invalid login test) is failing where it was passing with 0.0.4

subblue added a commit to subblue/redux-mock-store that referenced this issue Jan 5, 2016
In the test though I’m not sure how to properly catch the failing mock
test and test it’s error state
@subblue
Copy link
Contributor Author

subblue commented Jan 5, 2016

The tiny tweak in my pull request fixes the issues I was having when testing my app. However, I'm not sure how to properly test the test in the redux-mock-store tests!

@acrognale
Copy link

+1, I am experiencing the same issue and can confirm that switching back to 0.0.3.

I had spent a while trying to figure out if one of my own tests passing was related to my usage of nock or fetch, but this is indeed now correctly failing.

In my case, with v0.0.4, running mocha with NODE_ENV=production mocha ./src/tests/foo.jsx -G -R spec --ui bdd --compilers js:babel-core/register --recursive -d simply caused mocha to exit, without saying if the test passed or failed.

arnaudbenard pushed a commit that referenced this issue Jan 8, 2016
In the test though I’m not sure how to properly catch the failing mock
test and test it’s error state
@arnaudbenard
Copy link
Contributor

Fixed in v0.0.6

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

No branches or pull requests

5 participants