Just wanted to share a resource that may be useful to some in this community. For one of my projects, I wanted to write tests around various resource loading behaviors (<script>
, <link rel=preload>
, etc), but I didn’t want to have to run a server to back those resource requests.
So, I built a mock of the relevant parts of the DOM API that emulates the behavior seen when making these related DOM API calls:
Mock-DOM-Resources lets you create “DOM instances” that are configured to behave in a certain way, including delays for a resource loading (or erroring on load), whether certain features are supported by that DOM instance, etc. It works in both the browser and node.
If anyone here finds Mock-DOM-Resources useful, I’d love to have contributors on the project.