找不到变量:幻影中的承诺

人气:228 发布:2022-10-16 标签: javascript unit-testing tdd phantomjs karma-jasmine

问题描述

我正在用Jasmin编写测试用例。

当我调用Bellow方法时,

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

即:

initialize: function(config) {

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

    return new Promise(function(resolve, reject) {

    console.info("promise");

    resolve(true);
    });
}

我出现以下错误

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

安装的Pantom js版本为2.1.1

推荐答案

承诺支持在PhantomJS中不存在。 See the issue in github here。您可以使用ES6-Promise或Promise-PolyFill来启用Promise支持。如果可能,我建议迁移到Puppeteer

695