CasperJS test doesn't return after execution

妖精的绣舞 提交于 2020-01-05 19:59:20

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/18347685/casperjs-test-doesnt-return-after-execution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!