assuncaocharles/react-indexed-db

TypeError: Cannot read property 'open' of undefined

theresasogunle opened this issue · 1 comments

When running initDB(DBConfig) in a test, like Jest. TypeError: Cannot read property 'open' of undefined is displayed

The reason why our test didn't work is because indexedDB is undefined in the global namespace; IndexedDB is a browser API, so does exist in the global namespace in a browser's window object, but in a Node environment, the global object does not have an IndexedDB.

Testing your IndexedDB code with Jest