I want to test my app that use indexedDB, and becouse of indexedDB my tests dont work, shoud I set up indexedDB for tests, and what correct way to do it.
My code
beforeEach(() => {
cy.request({
method: 'POST',
url :'http://localhost:3000/api/auth/login',
body : {
email: "name",
password: "Passwprd"
}
}).then(function(response) {
loadScript('https://unpkg.com/localforage@1.5.5/dist/localforage.js').then(() => {
window.indexedDB.open("testDB");
localforage.config({
driver: [localforage.INDEXEDDB],
name: 'timesheetstestDBDB',
storeName: 'testDB',
version: '1.0',
});
})
localforage.clear().then(() => {
localforage.setItem('jobs', [{name: 'fdf'}]);
});
}).then(()=>{
cy.visit('http://localhost:3000/');
})
})
Component that I want to test use indexedDB requests for first component load, and I get error from cypress
Unhandled Rejection (OpenFailedError): UnknownError Internal error opening backing store for indexedDB.open.
UnknownError: Internal error opening backing store for indexedDB.open.
I just want to now way to run tests, and open indexedDB connection for end to end cypress enviroment.
Normal queries to the server work fine in automatic mode, but on queries to the indexedDB tests fail, because in the environment that opens cypress indexedDB is not open.
I run my app as "cypress": "cypress open" in package.json file
