Why I am not able to render my ReactJS application using PhantomJS 2.1.1?

后端 未结 2 1140
刺人心
刺人心 2020-11-30 14:11

In order to test my react app using webdriver.io, I need to launch it using phantomjs.

At first I thought the problem was webdriver.io but I\'ve realized that Phanto

相关标签:
2条回答
  • 2020-11-30 14:27

    You can download PhantomJS 2.5.0 Beta at https://bitbucket.org/ariya/phantomjs/downloads.

    It features updated QtWebKit engine that supports ES6 natively.

    0 讨论(0)
  • 2020-11-30 14:38

    Probably has to do with the lack of ES6 support in PhantomJS. To check I added page.onError() callback to your script (always handy!) and opened some React example site to get this error:

    ReferenceError: Can't find variable: Symbol

    To polyfill Symbol one can inject a core.js script from this excellent package into the page before loading the target url:

    page.onInitialized = function() {
        if(page.injectJs('core.js')){
            console.log("Polyfills loaded");
        }    
    }
    

    But that's for opening external sites. If the site that's being tested is under your development (as localhost url suggests) you probably could do with just configuring babel as is shown in this answer.

    0 讨论(0)
提交回复
热议问题