Simon
Simon

Reputation: 1829

CasperJS test doesn't return after execution

I'm having a problem getting casperjs test to exit after execution, I have to hit CTL-C to exit execution. I'm on OSX 10.7 with casperjs 1.1 devel.

To test this wasn't my code I simply copied this sample from the docs:

var casper      = require("casper").create();

function Cow() {
    this.mowed = false;
    this.moo = function moo() {
        this.mowed = true; // mootable state: don't do that at home
        return 'moo!';
    };
}

casper.test.begin('Cow can moo', 2, function suite(test) {
    var cow = new Cow();
    test.assertEquals(cow.moo(), 'moo!');
    test.assert(cow.mowed);
    test.done();
});

And I get the following output

casperjs test cow-test.js
Test file: cow-test.js
# Cow can moo
PASS Subject equals the expected value
PASS Subject is strictly true

I then have to hit CTL-C to stop execution. Am I missing something to stop execution?

Upvotes: 1

Views: 897

Answers (1)

Simon
Simon

Reputation: 1829

Per https://github.com/n1k0/casperjs/issues/593#issuecomment-23062361, the problem was that I had created a casper instance at the top of the file, which the documentation warns you not to do.

The solution was to remove the var casper = require("casper").create(); line.

Upvotes: 2

Related Questions