Kai
Kai

Reputation: 41

Grunt and CasperJS Testing - No exit or termination (only with CTRL+C) on Windows

I'll try to setup an testing environment with CasperJS and grunt. Everything is working as expected and the testing is working well.

I have only one problem. I have to press CTRL+C in the terminal to exit the test. This is a big problem, when I run this task in a CI tool such as Jenkins because the CasperJS/PhantomJS process is blocking the grunt process and therefore the build will never be successful.

Has someone any idea how to solve this problem?

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' ]
        }
    }
}

Upvotes: 1

Views: 188

Answers (1)

Kai
Kai

Reputation: 41

I'll checked the PATH environment and everything was fine. If I am execute the casperJS script with SlimerJS everything works fine. So I start searching the problem in phantom. I started the phantomJS as standalone application and tried to use phantom.exit() method. Result was the same as in the gradle + grunt build environment. So I started to find the problem in phantomJS and here we go - this is happening when you have a Nvidia GF 620 or similar. I tried my setup in a virtual machine with windows, and on physical machines with Debian Linux and OS X. Everything works fine.

The problem is solved in PhantomJS 2.0 for Phantom 1.X versions look at

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

or use google and search for "PhantomJS Nvidia exit"

Upvotes: 1

Related Questions