Running a script with execjs that uses window and document

I need to call a method from within a JavaScript file using execjs in python. This file has many window and document calls. So, execjs is not able to compile it. Is there any way to bypass this limitation of execjs? I only need one method from within the file but it has so many other methods it calls which call other methods. Anyway, here is what I have tried so far:

  1. I have tried putting mockup window and document variables. Though, adding/fixing something would break another. So, I finally gave up.
  2. I have considered extracting the method and the method it calls but they are too much. An AI recommended using several extraction methods and tried them but none of them worked.
  3. I have used PhantomJS but it turns out it does not support promises and the script uses those. I cannot use selenium because of my special use case. I want a solution small in size and also portable.

Your feedback is appreciated.