I'm trying to refresh the DB before each test to have my tests completely isolated. I imported fake-indexeddb/auto in the top of test file and use beforeEach to call FDBFactory inside (like in README example). Is it a correct way to refresh db ?
import 'fake-indexeddb/auto';
import FDBFactory from 'fake-indexeddb/lib/FDBFactory';
beforeEach(() => {
new FDBFactory();
});
global.indexedDB = new FDBFactory(); is what you want, because all new FDBFactory(); does is create a new variable, which has no effect if you don't assign it to anything.
I'm trying to refresh the DB before each test to have my tests completely isolated. I imported
fake-indexeddb/auto
in the top of test file and usebeforeEach
to callFDBFactory
inside (like in README example). Is it a correct way to refresh db ?