DEV Community


How do you test code that uses browser api's?

Omar White
Hi my name is Omar, I’m a software engineer that specializes in creating great front end experiences, primarily using react. When I’m not engineering I like to game and make music.
・1 min read

I've been working with the Web Payment Request API recently and have found that its kind of a pain to test my code. The solution i've come to is writing wrapper functions for the browser API calls and mocking those in my tests. This allows me to isolate the browser API code and test around it, but i'm wondering if there is a better way. I would appreciate any insights.

Discussion (0)