微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angularjs – 通过构建服务器运行时未捕获PhantomJS

我正在使用Karma和PhantomJS与Jasmine来测试我的AngularJS.当我在本地运行我的gulp测试时,它工作正常,启动PhantomJS并运行我的所有测试,但是当测试在构建服务器上运行时,它会失败并出现以下错误

请注意,我正在使用VSTS并使用其内置的云构建系统(托管代理).说它几乎是一个任务运行器,我只使用它来运行gulp任务(构建,测试等)在checkin上

[32m13 07 2016 15:21:32.260:INFO [karma]: [39mKarma v1.1.1 server started at http://localhost:9876/
[32m13 07 2016 15:21:32.262:INFO [launcher]: [39mLaunching browser PhantomJS with unlimited concurrency
[32m13 07 2016 15:21:32.284:INFO [launcher]: [39mStarting browser PhantomJS
[33m13 07 2016 15:22:32.285:WARN [launcher]: [39mPhantomJS have not captured in 60000 ms,killing.
[33m13 07 2016 15:22:34.287:WARN [launcher]: [39mPhantomJS was not killed in 2000 ms,sending SIGKILL.
[33m13 07 2016 15:22:36.288:WARN [launcher]: [39mPhantomJS was not killed by SIGKILL in 2000 ms,continuing.

我的Karma配置是:

var configuration = {
    basePath: "",files: listFiles(),singleRun: true,autoWatch: false,//usePolling: true,//transports: ["xhr-polling","jsonp-polling"],frameworks: ["jasmine","angular-filesort"],angularFilesort: {
        whitelist: [path.join(conf.paths.src,"/**/!(*.html|*.spec|*.mock).js")]
    },ngHtml2JsPreprocessor: {
        stripPrefix: "src/",moduleName: "veriApp"
    },browsers: ["PhantomJS"],//browsers: ["Chrome"],plugins: [
      "karma-chrome-launcher","karma-phantomjs-launcher","karma-angular-filesort","karma-jasmine","karma-ng-html2js-preprocessor"
    ],preprocessors: {
        "src/**/*.html": ["ng-html2js"]
    }
};

这是我的package.json的相关部分.请注意,在运行测试之前执行NPM安装

"karma": "1.1.1","karma-angular-filesort": "1.0.0","karma-jasmine": "1.0.2","karma-ng-html2js-preprocessor": "1.0.0","phantomjs-prebuilt": "2.1.4","karma-phantomjs-launcher": "1.0.0","karma-chrome-launcher": "1.0.1",

我已经尝试过关于此的各种答案的建议,但似乎没有工作!也许我错过了什么?

所以…解决方案非常简单,但需要一段时间才能找到:

在构建设置的“变量”选项卡下,添加一个环境变量:

PHANTOMJS_BIN C:\NPM\Modules\PhantomJS.cmd

感谢this linkthis link.

原文地址:https://www.jb51.cc/angularjs/141451.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐