sinon-chrome
sinon-chrome copied to clipboard
How to test DOM update without displaying the page?
Hi,
I am using Sinon-Chrome to test a Chrome extension. One of the functions is that user can highlight text on a web page. This is how I think I can test this with Sinon-Chrome:
- Send the extension an text selection event (using Sinon-Chrome);
- The extension updates the DOM to change the text background;
- Check if the background of the selected text is changed, such as marked with
<mark>
.
I think I can do step 1, but don't know how to do step 2 or 3 if I don't want to open a real URL in browser. How to give the Chrome extension a DOM to update (and then check) without open an actual website?
Ideally such a (virtual?) DOM can be loaded from a pre-saved file, so 1) it will be exactly the same every time, and 2) it makes the test synchronous (open a real URL will be asynchronous).