javascript - CasperJS的Hello-test.js运行错误
伊谢尔伦
伊谢尔伦 2017-04-11 09:12:50
[JavaScript讨论组]
// hello-test.js
casper.test.begin("Hello, Test!", 1, function(test) {
    test.assert(true);
    test.done();
});

$caspserjs hello-test.js
运行之后出现错误,我是照抄的官网的例子a-minimal-testing-script
帮忙看一下,是什么问题?
error:

$ casperjs test hello-test.js
2016-02-04 11:00:19.878 phantomjs[17344:140800] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
Test file: hello-test.js
FAIL TypeError: 'undefined' is not a function (evaluating 'casper.test.begin("Hello, Test!", 1, function(test) {
    test.assert(true);
    test.done();
})')
#    type: uncaughtError
#    error: "TypeError: 'undefined' is not a function (evaluating 'casper.test.begin(\"Hello, Test!\", 1, function(test) {\n\ttest.assert(true);\n\ttest.done();\n})')"
TypeError: 'undefined' is not a function (evaluating 'casper.test.begin("Hello, Test!", 1, function(test) {
    test.assert(true);
    test.done();
})')
  /Users/wangqi/Documents/workspace/casperjs/hello-test.js:10
FAIL 1 tests executed in 0.014s, 0 passed, 1 failed.

Details for the 1 failed test:

In hello-test.js:0
   uncaughtError: TypeError: 'undefined' is not a function (evaluating 'casper.test.begin("Hello, Test!", 1, function(test) {
    test.assert(true);
    test.done();
})')
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(1)
PHPz

目前,CasperJS 稳定版的版本号是 1.0.x,但是官方网站的示例和文档是根据 1.1.x 开发版编写的,其中,begin() 就是从 1.1.x 开始开发的。

所以解决这个问题的方法就是将 CasperJS 的版本升级到 1.1.x 以上,如果是 Mac 平台,可以使用:

brew install casperjs --devel
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号