Skip to content

Intercept XMLHttpRequest through a Service Worker #287

@allthesignals

Description

@allthesignals

I use PretenderJS (via Ember Mirage) to help test dozens of apps. In most cases, it intercepts network requests perfectly.

However, I also use another 3rd party library (MapboxGL) which issues XMLHttpRequests from within Web Workers. This is a problem because I do not have direct control of their global objects.

Because most of my functionality is built on top of this 3rd party library, being able to test it would greatly improve my test coverage.

(For additional context, this SO question explains my situation exactly. The answer to it suggests a way to intercept these requests using Service Workers.)

I couldn't find another issue related to this, but I'm curious what others think. It seems like Service Workers would help us intercept fetch requests at another level. I'd love to dig into the code if there's an appetite for it, but I could also just be completely off base!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions