'Firebase emulator testing programmatically re-seed data between test runs

I'm currently trying to test a react.js/firebase app with cypress. I'm currently doing this with the firebase emulator by using "firebase emulators:start --import=saved_data" which imports the data I've saved at the start of the test runs.

However this means that during the test runs each test will effect the state of firestore, which means they won't be independent. Is there some way in cypress to programmatically re-seed the data to its initial state (as in the state the data was in when initially imported from saved_data before the other tests were run), perhaps by using some sort of beforeEach hook?

I know it's possible to completely clear the database before each test but that's not what I'm looking for.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source