在幻影中运行"casperjs测试" [英] Running 'casperjs test' in phantom
问题描述
所以我有一个在节点中运行的文件,该文件运行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屋!