I've built a Node app, and am adding unit tests. In my unit test file I need to create a mock DOM which has support for <script type='module'> tags. In other words, into my mock DOM I need to insert HTML which loads a JavaScript file JS via a <script type='module'> tag. Other than jest-dom, what options do I have to create such a mock DOM?
Of Note
If there are no other options, how might I get around my issue? Would I have to refactor my code so it does not use such a tag? Or at least, refactor things so my unit tests don't depend on that tag?
Motivation Behind Question
The motivation for this is this. In my project I have an HTML file which renders a simple form to the DOM, and a separate JS module which is loaded on the same page and serves as the form handler (i.e. it makes a specific fetch request when the submit button is clicked). I originally had an integration test written using Jest (using jest-dom as the mock DOM), which does the following:
There were no issues with that test. I'm now trying to refactor my automated tests away from Jest to Tape, with jsdom as the mock DOM.
Thanks.