schickling/chromeless

Evaluation of external JS not working

Closed this issue · 1 comments

I am passing an html-string through .setHtml() to chromeless, that contains an external js:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

Calling the a function in the script through evaluate does not seem to work:

    chromeless
      .setHtml(html)
      .wait(800)
      .evaluate(() => {
        console.log(jQuery().jquery);
      })
      .screenshot()

Logs show this error:

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ReferenceError: jQuery is not defined

Simpler, this does not generate an output in my logs:

chromeless      
      .setHtml(html)
      .wait(800)
      .evaluate(() => {
        console.log("this should create a log entry, right?");
      })
      .screenshot()

It looks like the issue lies with .setHtml(), as rendering a page in that manner js is not being evaluated. I uploaded the same html to S3 and called it through .goto("s3-location"), all js was executed fine.