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

getMockedActions returning "@thunk.<thunk_name>(start)" type thunk but not "@thunk.<thunk_name>(fail)" when the thunk throws an error #587

Open
LuisOsta opened this issue Oct 26, 2020 · 2 comments

Comments

@LuisOsta
Copy link

LuisOsta commented Oct 26, 2020

The Problem

This was working a couple of weeks back so I'm unsure why it's failing now. Essentially I'm writing a test case that a thunk fails when I expected it to.

As it's shown in the tutorial.

The store.getMockedActions() should return both the start of the thunk and the failed state of the thunk (if it fails).

Kinda like this (abbreviated example from the tutorial:

[
    { type: '@thunk.fetchById(start)', payload: todo.id },
    { type: '@thunk.fetchById', payload: todo.id },
]

But what I get from the functions is this:

[
    { type: '@thunk.fetchById(start)', payload: todo.id },
]

The Question

Do you have a sense of what could be causing this issue?
And if there's anything recent that could be causing it?

More Information

Test Runner

  • Jest

Store Configuration

const store = createStore(storeModel, {
      injections: {
        authService: mockAuthService,
      },
      mockActions: true,
});

Test Case In Question

test("The user should not be signed up if they provide an invalid email", async () => {
        const invalidUser = {
          ...signUpUser,
          email: "[email protected]",
        };

        expect(mockAuthService.signUp).not.toHaveBeenCalled();

        await expect(
          store.getActions().user.signUp(invalidUser)
        ).rejects.toThrow(Error("The email provided was not valid."));

        expect(mockAuthService.signUp).not.toHaveBeenCalled();
        expect(store.getMockedActions()).toEqual(
          expect.arrayContaining([
            {
              type: "@thunk.user.signUp(fail)",
              payload: invalidUser,
              error: Error("The email provided was not valid."),
            },
          ])
        );
});
@LuisOsta LuisOsta changed the title getMockedActions returning start element for thunk but not fail when the thunk throws an error getMockedActions returning "@thunk.<thunk_name>(start)" type thunk but not "@thunk.<thunk_name>(fail)" when the thunk throws an error Oct 26, 2020
@ctrlplusb
Copy link
Owner

Hi @LuisOsta - what version are you using?

@LuisOsta
Copy link
Author

@ctrlplusb Oh sorry for not including that info in the original one, slipped my mind.
The version used when I run npm list easy-peasy is 4.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants