I am just trying to handle impossible stuff in Cypress :) Basically I am taking token from indexedDB using 'idb' library -> https://www.npmjs.com/package/idb To get that I have created async function
export const getTokenFromIndexedDB = async () => {
const db = await openDB('StorageDB')
const keys = await db.getAllKeys('LocalStorage')
const key = keys.filter((key) => key.startsWith('authUser'))
const value = await db.get('LocalStorage', key[0])
return value.value.token
}
In the test I would like to make couple of API calls using the token. I am using that using then()
, but ending up with a big chains of commands. Is there any way to assign a value of the called function (to await for the value) in Cypress?
Other option is to call getTokenFromIndexedDB()
before each call, but this is not efficient.