I
I
Igor Shumilovsky2017-02-21 17:26:07
JavaScript
Igor Shumilovsky, 2017-02-21 17:26:07

How to test functions with document.createRange in a node.js environment?

I'm trying to test a component that has document.createRange in one of its methods. Jest tells me that document.createRange is not a function. Actually, window.getSelection is also missing. Does anyone know how to solve this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abberati, 2017-02-21
@abberati

document and window are global objects of the browser , not js. in fact, they are not in node.
it is possible to emulate the presence of a browser in node, for example, with a browser module without a shell

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question