CasperJS测试执行后不返回

CasperJS测试执行后不返回

本文介绍了CasperJS测试执行后不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在执行 casperjs测试后退出时遇到问题,我必须按CTL-C退出执行。我在OSX 10.7上使用casperjs 1.1开发。

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();
});

我得到以下输出

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

然后我必须按CTL-C才能停止执行。我是否缺少停止执行的内容?

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

推荐答案

每个,问题是我在以下位置创建了一个casper实例文件的顶部,文档警告您不要这样做。

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.

解决方案是删除 var casper = require( casper ).create(); 行。

这篇关于CasperJS测试执行后不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:20