Puppeteer, Jest, Unhandled rejection: MissingAPIError: indexedDB API not found
See original GitHub issueAs there are close to no resources on how to test indexedDB, I figured out that one way could be by end-to-end testing using Puppeteer and Jest. However with Dexie it throws this error:
Unhandled rejection: MissingAPIError: indexedDB API not found
This is clearly a Dexie.js error, if I try to open the indexedDB normally everything work as expected.
describe('IndexedDB', () => {
const puppeteerConfig = {
headless: false
};
let browser, page, db;
beforeEach(async () => {
browser = await puppeteer.launch(puppeteerConfig);
page = await browser.newPage();
await page.goto('http://localhost:3000', {waitUntil: 'networkidle2'});
db = require('../../../services/cache/indexedDb').default
});
afterEach(async () => {
await db.clear();
await browser.close();
});
describe('test', function () {
it('should test add', async function () {
await db.photos.add({id: 1, date: '2014-01-09'})
});
});
});`
my config
const tables = {
photos: "id, year, month",
};
const db = new Dexie(config.cache.dbName);
db.version(config.cache.version).stores(tables);
export default db;
Everything is working normally, not with Puppeteer and Chromium
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:12
Top Results From Across the Web
Puppeteer, Jest, Unhandled rejection: MissingAPIError ...
I have tried to initialize it from the renderer process first, then make use of it in the main process but still getting...
Read more >indexedDB is not defined" when testing React component ...
Actually, Jest is used to simulate the DOM in memory, not in an actual headless browser. For that reason, you have to mock...
Read more >MissingAPIError: indexedDB API missing
MissingAPIError : indexedDB API missing ``` 議論はここでされてて、 - [Puppeteer, Jest, Unhandled rejection: MissingAPIError: indexedDB API ...
Read more >Dexie.MissingAPIError
Description. Happens when indexedDB API could not be found when trying to open database. This is usually the case when using Dexie from...
Read more >Testing your IndexedDB code with Jest
The reason why our test didn't work is because indexedDB is undefined in the global namespace; IndexedDB is a browser API, so does...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That exception happens when there’s no indexedDB property present on the global object, specifically i in node. Dexie can be configured to rely on a given indexedDB implementation instead, such as fake-indexedDB or indexeddbshim. To enable that, do set the static properties Dexie.dependencies.indexedDB and Dexie.dependencies.IDBKeyRange prior to instanciating your Dexie instance
At least for me, they really don’t. Thats why I am asking for any workaround, like accessing the Dexie singleton in renderer one from renderer two.
Also, I’m not using a worker yet. For now, I just open windows (one main + children) and try to find a way to read/write to database using Pixie from the main window’s indexedDB (everything is being done on renderer process).