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

Is there a way to test multiple firestore states? #178

Open
idangozlan opened this issue Oct 4, 2023 · 1 comment
Open

Is there a way to test multiple firestore states? #178

idangozlan opened this issue Oct 4, 2023 · 1 comment

Comments

@idangozlan
Copy link

Hi,

I wonder if there's a way to mock a different firestore state per describe, for use cases when testing if a user exists or not, etc.

Thanks

@sbatson5
Copy link
Owner

sbatson5 commented Nov 2, 2023

That's tricky because of the way jest hoists mocks to the top of the function, regardless of where you define them. You can have a beforeEach call at the top of your describe block and then mocks in 2 separate it blocks

describe('mocks', () => {

    beforeEach(() => {
        jest.resetModules();
    });

    it('does a thing', () => {
       mockFirebase(...);
       // stuff here
    });

    it('does another thing, () => {
        mockFirebase(...);
       // other stuff here
    });
});

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

2 participants