gpt4 book ai didi

node.js - 在幻象中运行 'casperjs test'

转载 作者:搜寻专家 更新时间:2023-10-31 23:33:17 27 4
gpt4 key购买 nike

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

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 可以使用这个测试套件,但我在控制台中收到以下错误:

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

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

谢谢!

最佳答案

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

问题解决了。

您必须在 xyz.js 脚本的顶部包含这一行,以便 .test 属性变为真;

phantom.casperTest = true;

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

casperjs xyz.js

关于node.js - 在幻象中运行 'casperjs test',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19857139/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com