Grunt和CasperJS测试 - Windows上没有退出或终止(仅限CTRL + C)

时间:2015-10-12 00:19:21

标签: windows gruntjs phantomjs casperjs

我将尝试使用CasperJS和grunt设置测试环境。一切都按预期工作,测试运行良好。

我只有一个问题。我必须按终端中的CTRL + C退出测试。当我在诸如Jenkins之类的CI工具中运行此任务时,这是一个大问题,因为CasperJS / PhantomJS进程阻止了grunt进程,因此构建永远不会成功。

有人知道如何解决这个问题吗?

Casper-Test-File:

var config = require('../../config.json');

casper.test.begin("Testing Homepage QuoteBox", 0, function suite(test){

    casper.start(config.url);

    casper.then(function() {});

    casper.then(function() {});

    casper.run(function() {
        test.done();
        this.exit();
        phantom.exit();
    });

});

GruntFile.js:

casper : {
    yourTask : {
        options : {
            test : true,
            'log-level' : 'error',
            'fail-fast' : true,
            'ignore-ssl-errors' : 'yes',
            'load-images' : 'no',
            'verbose': 'no',
            concise : true
        },
        files : {
            'xunit/casper-results.xml' : [ 'front-end-test/casper/**/*.js' ]
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我检查了PATH环境,一切都很好。如果我用SlimerJS执行casperJS脚本一切正常。 所以我开始在幻影中搜索问题。我将phantomJS作为独立应用程序启动并尝试使用phantom.exit()方法。结果与gradle + grunt构建环境中的结果相同。所以我开始在phantomJS中找到问题,在这里我们去 - 当你有一个Nvidia GF 620或类似的时候会发生这种情况。我在带有Windows的虚拟机和使用Debian Linux和OS X的物理机上尝试了我的设置。一切正常。

PhantomJS 2.0 for Phantom 1.X版本的问题解决了

https://github.com/ariya/phantomjs/issues/10845

或使用谷歌搜索" PhantomJS Nvidia退出"