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

merge with firebase-mock #29

Closed
soumak77 opened this issue Sep 28, 2018 · 6 comments
Closed

merge with firebase-mock #29

soumak77 opened this issue Sep 28, 2018 · 6 comments

Comments

@soumak77
Copy link

I'm wondering whether you would like to merge this library with firebase-mock. I am the developer of that project and would be happy to assist in any way to help merge the feature set from this library. From what I can tell the only key difference is in how you initialize your dataset. Once the data is initialized, the libraries appear to be very similar. There may be some outstanding issues which prevent you from wanting to switch mocking libraries, but I'm sure we can work through them.

@mikkopaderes
Copy link
Owner

I'd love to but unfortunately I wouldn't be able to help that much with the merging. I quickly hacked this before for my personal use and only touch this library when really needed due to lack of time.

I read somewhere in stackoverflow that the Firebase team has a mocking library in their pipeline so I've just been using this for the meantime until that official library pops up.

@soumak77
Copy link
Author

I didn't know firebase had plans to provide a mocking library. Thanks for the consideration.

@mikkopaderes
Copy link
Owner

Here's a reference to what I'm saying. That's way back in 2017 so... 😞

@Venryx
Copy link

Venryx commented Oct 23, 2019

Hmm, a clear difference seems to be that firebase-mock must be run in NodeJS (ie. with access to the "fs" module, as seen here), whereas mock-cloud-firestore can run entirely in the browser (since its data-store is in regular js-objects/memory, as seen here).

Is this distinction accurate, or am I misunderstanding?

Anyway, if true, this makes mock-cloud-firestore better for my use-case, because it means I can more easily integrate the mocking library with Cypress. (Cypress tests run in the browser alongside the main application code)

If so, would be nice to have a mention of this distinction somewhere, as it's led to quite a bit of confusion as I've evaluated the different firestore-mocking options.

  1. firebase-mock (NodeJS required)
  2. mock-cloud-firestore
  3. firebase-server (Firebase only)
  4. Cloud Firestore Emulator

EDIT: Created an issue for this here: soumak77/firebase-mock#157

@Venryx
Copy link

Venryx commented Oct 23, 2019

On looking closer at firebase-mock, it looks like the uses of fs are just for some extra features like downloading files? (the js-object/memory datastore seems referenced here: https://github.com/soumak77/firebase-mock/blob/master/src/firestore-document.js#L124)

If so, is there a way to exclude the NodeJS-requiring portion of the library? At the moment, it's causing Webpack errors when attempting to import firebase-mock from in-browser code.

EDIT: For now I'm getting around the issue by adding fs to Webpack's externals config:

webpackConfig.externals = {
	// Replace `require("firebase-mock")` with another module/global-variable (I used "React")
	// (needed for firebase-mock in browser -- code-path not actually used, so it's okay)
	fs: 'root React',
};

@mikkopaderes
Copy link
Owner

I'm not the maintainer nor a user of firebase-mock so I can't answer your question for that.

For the distinction, yes this library is suited to run in the browser and nodejs. However, I recommend using the firestore emulator in nodejs as that's the official testing solution for it. That's also the reason why I'll be reluctant on adding nodejs specific API if any in the future.

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

3 participants