I honestly don't comment on KZbin videos much, but Todd, you're videos are always extremely well done and helpful! I just had to share how much I (and I'm sure many others) enjoy the work you do helping everyone learn how to use Firebase in better ways
@agung_laksana2 жыл бұрын
please make a new video, the syntax is no longer valid for the latest npm package
@quangle57013 жыл бұрын
Excellent step-by-step instructions of how to do unit test for cloud firestore with firebase emulator. Thank you very much.
@Firebase3 жыл бұрын
You are welcome!
@scottmyers64884 жыл бұрын
Excellent, the best tutorials ever. Completely generous!
@mmathems395 Жыл бұрын
Thank you for this one Todd, I went through this a lot today and hopefully it'll see me through what I'm currently stuck on. Nice, clear and very well explained examples. If I may also say, I am still amazed at how you managed to emulate the various circumstances in order to test them, and further amazed by how you'd be sure that the circumstances were being perfectly emulated ... It's coming from me thinking about other circumstances to emulate, and how I could be sure that I have set the circumstances perfectly. Many thanks.
@thepickicool974 жыл бұрын
While we're here, I'm still wondering why there's no solution from Google for full text search in firestore. Even a separate solution would be okay. Algolia is soooooooo expensive !
@clivehtownsend4 жыл бұрын
2:14 is pretty much how I live my life.... "Somewhat recent version of Java. I don't actually know what the precise minimum version is. I have XX installed and that seems to work"
@pebuchmann3 жыл бұрын
This video is equally helpful and fun to watch! Be careful not to miss the "await" statement when writing docs as admin to the database because if not this leads to seemingly erratic behaviour.
@LautaroGruss3 жыл бұрын
AWESOME. Seriously, you explain it so clear! 100!
@Firebase3 жыл бұрын
Glad it was helpful!
@GeoffreyHale3 жыл бұрын
Great tutorial! Thorough and easy to follow. So helpful. Thank you!
@dc54 жыл бұрын
Awesome video as always, thank you Todd! Looking forward to the next one.
@gavindavis963 Жыл бұрын
Is there an updated version of this process. @firebase/testing is deprecated and points to @firebase/rules-unit-testing. However, when I install the latest version of @firebase/rules-unit-testing the code in the video does not work. Specifically 'TypeError: firebase.initializeTestApp is not a function'. I am proceeding with @firebase/rules-unit-testing v1.3.7 as this seems to work. But just wondering if the new process has been explained
@NayanBhakhar-k1x Жыл бұрын
I also faced same issue as you mentioned here
@viczking85204 жыл бұрын
anyone know how to fix FirebaseError: Failed to get document because client is offline. I've tried running firebase emulators:start at project level and even test level. The emulator starts at port 5000 correctly and all are online as in on emulator UI. So why does it say that the client is offline!!!!!!!!!!!!!!!
@xujok3 жыл бұрын
Just 1 year later the library has been detracted the API changed and nothing works after update ...
@markgoho4 жыл бұрын
The MY_PROJECT_ID needs to be exactly the same as what the emulator knows from your local project or changes to security rules will not be picked up
@felippewick2 жыл бұрын
"Let's just add an email for fun - uh, that was fun. *I need to get out more*" 😂
@theophileavoyne42523 жыл бұрын
The @firebase/testing package has been deprecated. Could you do a video tutorial explaining how to use @firebase/rules-unit-testing?
@theophileavoyne42523 жыл бұрын
@@ToddKerpelmanCorp Looking forward then! Thank's for your valuable videos, you have a real teaching talent.
@chiubaca4 жыл бұрын
I'm trying to follow along but I've getting a mocha error Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (..\firebase-auth-testing\tests\test.js)
@9642arvind4 жыл бұрын
I got the same error. I resolved it by ensuring my emulator was running using firebase emulators:start
@b0otable4 жыл бұрын
You need to make sure the emulator is connected. I had the issue as I was running on non-default ports. My changes: 1.) I changed to the updated @firebase/rules-unit-testing 2.) const db = firebase.initializeTestApp({projectId: MY_PROJECT_ID}).firestore(); db.useEmulator("localhost", 8086)
@bartl97983 жыл бұрын
It's a bit confusing that this library got renamed to @firebase/rules-unit-testing because a lot of its functionality seems useful for testing Firebase in general (such as clearing the database).
@mmathems395 Жыл бұрын
True, and I encountered the same problem earlier today. The solution was to change the version of @firebase/rules-unit-testing to 1.3.15 (the version I saw working within the Google Cloud Shell Editor. After that and reinstalling npm, this video could be followed.
@niklasopf3 ай бұрын
This tutorial was fantastic!
@danvilela4 жыл бұрын
Thank you Todd! Your videos are helping me a LOT!
@Ganeki-san2 жыл бұрын
Please god update this code to use version 9 SDK, your docs link to this video but your docs literally recommend to ppl to use the version9 instead of this.
@peteredmonds17122 жыл бұрын
This was a great video, but is honestly should probably be removed. This is not the current way to do unit testing in Firebase and the mix of information is confusing
@rachelmmyers2 жыл бұрын
I think the value proposition of this video is that is explains the moving parts of testing Security Rules using the Emulator Suite. Our libraries will evolve, and documentation will always be more up to date than videos.
@nikolairivas96152 жыл бұрын
@@rachelmmyers I think it would be helpful to provide a sample file with the new library setup process as opposed to the random code snippets that are provided in the documentation. For those who already know the mechanics of this stuff, the code snippets may be adequate, but I believe most people who turn to KZbin for help are beginners and thus have little-to-no experience with setting up a test suite. If anything, I think it would be helpful to provide a short video explaining the new setup, as the rest of the process seems relatively unchanged.
@startover3055 ай бұрын
Does anybody where the next episode is 🤔? The playlist doesn’t seem to have the matching content mentioned in the video, like list
@kishan02patel4 жыл бұрын
At 2:33 the command should be `npm i -g firebase-tools`. You might also need to add `sudo` in front of it. Thanks for the video!
@dharmarajr244 жыл бұрын
I have watched this somewhere... Like yesterday XD ... But watching Todd again n again is fun n his lessons are interesting
@stoem4 жыл бұрын
I cannot get past the Java dependency for the emulators. I had to install Java on my Mac, found that appears to be the latest version jre-8u261-macosx-x64.dmg which then gives me java version "1.6.0_65" in the Terminal whilst the emulator insists on 1.8 or higher. Setting this up is a rabbit hole inside a rabbit hole.
@piotrkucuyma23423 жыл бұрын
05:34 I would love to know more about the "kraken-control-panel" project on the list though.
@chuguloco4 жыл бұрын
Could you please give me the link to the video refered in 12:04?
@b0otable4 жыл бұрын
A lot of this does not work when using WSL
@nicolapigozzo4 жыл бұрын
#askFirebase am i wrong or map fields are not supported on the new security rules? why can't I map a field like this: allow create: if !('userDetails.status' in incomingData());
@nicolapigozzo4 жыл бұрын
btw @RachelMyers #askFirebase you have an error on your last blog post, please remove the bracket: allow create: if request.resource.data.keys().toSet() .hasOnly(["required","and","optional","keys"]). firebase.googleblog.com/2020/06/new-firestore-security-rules-features.html
@mjonausk3 жыл бұрын
Hmmm the assertSucceds and assertFails did not seem to work for me. I had to write my own little functions const isDocumentAccessible = async (db, path: string): Promise => { let isAccessible: boolean = true; try { await db.doc("/business/ABNMJ/expenses/2020/quarters/qtr1/items/item1").get(); } catch { isAccessible = false; } return isAccessible; };
@hugobotas84474 жыл бұрын
Can't wait for the next one!
@enlightened_monkey87674 жыл бұрын
firebase real time database is not working in india from sep3 2020 and still there is no response from firebase team
@the_potato_god123 жыл бұрын
The codelab isn't available anymore?
@albertgao72562 жыл бұрын
super good topic!!! guess i can do the same thing to test my realtime db validation as well!
@StanleySathler Жыл бұрын
Great video, Todd, thanks! I wish Google just updated their tutorials as they update the codebase - turns out `@firebase/testing` is now deprecated and we should use `@firebase/rules-unit-testing` instead
@MrPeter7e4 жыл бұрын
hi what happened with the pathway "Validate app behavior and verify security rules with Firebase Emulators"? I could completed it in google.dev, but I do not find it now.
@rubenheymans19883 жыл бұрын
how can you use the playground to test with multiple tenants?
@MaximilianBeck4 жыл бұрын
Great introduction! Can you expand on when to use what project id for initialisation of the test sdk?
@duanehodges31464 жыл бұрын
Is there a way to add thousands of documents to firestore for testing purposes?
@ryansampson7221 Жыл бұрын
Darn. This video is severly outdated. Worst of all, its what the official docs point to still.
@StanleySathler Жыл бұрын
Classic Google style unfortunatelly.
@luthiers54884 жыл бұрын
Please make more videos on this topic, like for example when a document is updated/deleted
@antuancaraballo96914 жыл бұрын
Very valuable, thank you for sharing!
@carlosaltamera3534 жыл бұрын
This is just excellent. Thanks!
@mattnicolls52533 жыл бұрын
Can you please provide a link to the end working code in the description
@georgedicu73972 жыл бұрын
Is there any flutter/dart examples?
@StephenMoreira4 жыл бұрын
This was gold. Thanks.
@Ondal14 жыл бұрын
I'm really missing something like this for firebase function acting as triggers for CUD operations. Particularly when testing collection modifications which result in other collection documents being changed. Currently I can only get it working with ONE document change, where the code which should delete the database doesn't do so.
@9642arvind4 жыл бұрын
Could you also share best practices on splitting the code in the firestore.rules file and the test.js file
@davidtheprogrammer4 жыл бұрын
Was looking for this. Can't find anything on this
@jerrythomas87274 жыл бұрын
Can we use firebase emulators to test authentication also? If yes how?
@abderraoufsalah43713 жыл бұрын
What about realtime database
@nussknacker27194 жыл бұрын
How can I test a query (list)?
@Norfeldt4 жыл бұрын
Great video as always Todd 👏 Perhaps you could show how to setup a CI with the emulator (would be nice if it was using GitHub actions)?
@chuguloco4 жыл бұрын
Excellent tutorial!!!
@AdamBeguelin4 жыл бұрын
I want my app to be able to create documents but not read or write those documents once they are created. Is this possible? I'm using cloud functions to process the documents but don't want the app to be able to come back and update the document, even if it's the owner of the document.
@cottz67184 жыл бұрын
Hi Adam, you can make a rule like if the data coming is the same as the data in the database, in that case is impossible to change the original data.
@mattfrowe76974 жыл бұрын
Great tutorial, thank you!
@VladimirBrasil4 жыл бұрын
Beautiful video: huge congrats! Functions will be nice to learn to test, probably in a future video. Pubsub as well, but maybe less users would appreciate (I would).
@9642arvind4 жыл бұрын
Thanks for the wonderful video! Please help me with this use case - I have a restaurant collection with restaurant documents. 1) Certain fields in this document (like restaurant name, timings, etc) can be updated by owners or by admin users with special custom claims. 2) Certain fields (like ratings, popularity, visit count) CAN NOT be updated by any user (will be updated using cloud functions). 3) Certain fields (like internal flags) can only be updated by users with the special custom claim and not by owners. Thank you for your response!
@YousefSh3 жыл бұрын
I'm confused. You imported the firebase admin SDK to add a document to the firestore running in the emulator. Then how would use you use the admin SDK to add a document to the production database?
@YousefSh3 жыл бұрын
Like, you didn't add any config to the admin SDK telling it whether to write data to the emulator or the production SDK. So why did it go to the emulator by default?
Request for a video helping with Firestore security rules coverage?
@vballaddict752523 жыл бұрын
Hint: DON'T type a rule description as "if(...)" instead of "it(...)" because (a) it won't show up as an error and (b) it'll be difficult to track down! LOL
@argada4 жыл бұрын
Excellent video! Question, what would be an elegant way to ensure the emulator starts and is available for use prior to proceeding with test execution?
@bartl97983 жыл бұрын
Use firebase emulators:exec "test command"
@ashtonthomas34744 жыл бұрын
I think you wanted `npm i -g firebase-tools` and not `npm -i g firebase-tools` @2:30
@AndreiNedelus4 жыл бұрын
I'm wondering how you set-up the firebase rules with a framework like react
@dahnmaier47734 жыл бұрын
Same. They are framework agnostic (firebase init). You can run the same tests with jest.
@clivehtownsend4 жыл бұрын
Also, 2:23 should read ```npm i g firebase-tools``` instead of ```npm -i g firebase-tools``` Thanks for the video!
@yannneq4 жыл бұрын
Great video, i have been looking for something like this! The rule at 21:47 did not work form me, though. allow read: if (request.auth.uid == resource.data.userId) i had to use this instead: allow read: if (request.auth.uid == request.resource.data.userId)
@YousefSh3 жыл бұрын
Is this possible for storage rules too?
@YousefSh3 жыл бұрын
Meaning, running unit tests against the rules?
@topgeargaming86794 жыл бұрын
What do u mean by "if true" and "if false" why not just "true" and "false".
@JulienReszka3 жыл бұрын
Firebase/testing is deprecated, use @firebase/rules-unit-testing
@miguelchavez86904 жыл бұрын
I cannot pass to kzbin.info/www/bejne/jHXYnamcd9WtkKc I keep getting this error after I ran the emulators, cant find a solution, any ideas? @firebase/firestore: Firestore (7.16.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: 14 UNAVAILABLE: Connection droppedThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. My internet connection seems fine, thanks!