在幻影中运行"casperjs测试" [英] Running 'casperjs test' in phantom

查看:69
本文介绍了在幻影中运行"casperjs测试"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个在节点中运行的文件,该文件运行PhantomJS的本地副本,如下所示:

So I have a file running in node which runs a local copy of PhantomJS as below shows:

phantom.casperPath = 'node_modules/casperjs';
phantom.injectJs('node_modules/casperjs/bin/bootstrap.js');
var casper = require('casper').create({
    viewportSize: config.viewportSize
});

casper.test.begin('Runing tests here', 5, function suite(test) {
    // Tests here
});

没有casper.test.begin(),我的测试功能正常.我具有可以使用此测试套件的正确版本1.1.0,但是在控制台中出现以下错误:

Without the casper.test.begin() my tests function fine. I have the correct version 1.1.0 which can use this test suite but I get the following error in my console:

CasperError: casper.test property is only available using the `casperjs test` command

CasperJS文档也提到了这一点: http://docs.casperjs.org/en /latest/testing.html .我的问题是如何在上述代码中的此命令下运行此Casper,以便可以使用这些测试?

The CasperJS docs mentions this too: http://docs.casperjs.org/en/latest/testing.html. My question is how do I run this Casper under this command in the above code so I can use these tests?

谢谢!

推荐答案

CasperError:casper.test属性仅可通过casperjs test命令使用

问题解决了.

您必须在xyz.js中的脚本顶部包含此行,以使.test属性变为true;

You have to include this line at the top of your script in your xyz.js, so that the .test property becomes true;

phantom.casperTest = true;

那么您应该没有问题,从终端启动:

Then you should have no problem Launching from the terminal:

casperjs xyz.js

这篇关于在幻影中运行"casperjs测试"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆