DEV Community

Discussion on: How to write tests for a library that requires being run on the browser (like Dexie.js or localforage)?

Collapse
 
evanplaice profile image
Evan Plaice

If you need DOM access, some testing libraries like Jest provide a sort of pseudo-DOM that you can interact with and mock out the parts that aren't provided.

There is also JSDOM which is a Node implementation of the DOM that you could use with testing tools like Mocha/Chai that don't have built-in DOM support.

If you want full browser automation then you'll need an E2E testing tool. For that there's tools Puppeteer, Cypress.io. I don't recommend Selenium.

Collapse
 
johnson_cor profile image
Corey Johnson

I'll look into Jest & check those E2E tools out! Thanks!