Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find variable: Promise in Phantomjs

I am writing test cases with Jasmin.

When I call bellow method,

initialize({"Data": "primary"});

Which is:

initialize: function(config) {

    console.info("initialize Version 2 initialized..");

    return new Promise(function(resolve, reject) {

    console.info("promise");

    resolve(true);
    });
}

I am getting below error

ReferenceError: Can't find variable: Promise in http://localhost:8080/absolute/home/krushanu/project/krushanu/ekstep/theLib/js-libs/telemetry/telemetry.js?a043c6a23b1af06737d8e1ae1e1c2e152d4faa83

Installed phantom js Version is 2.1.1

like image 273
KRUSHANU MOHAPATRA Avatar asked Oct 30 '17 09:10

KRUSHANU MOHAPATRA


1 Answers

Promise support is not present natively in PhantomJS. See the issue in github here. You could use es6-promise or promise-polyfill to enable Promise support. If it is possible, I would recommend migrating to Puppeteer

like image 75
ajaybc Avatar answered Nov 04 '22 23:11

ajaybc