首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在CasperJS中分割测试文件-与其逻辑斗争

在CasperJS中分割测试文件-与其逻辑斗争
EN

Stack Overflow用户
提问于 2014-08-29 13:48:29
回答 1查看 783关注 0票数 4

由于Stack的其他许多人都在苦苦挣扎,我正在尝试将我的CasperJS测试拆分到多个文件中。我花了三天时间阅读文档,在这里搜索答案,似乎找不到任何有帮助的东西。

我有三个脚本(安装、函数、清理),其中包括使用--预、后和-包括命令。当我单独运行每个测试文件时,它工作得很好:

代码语言:javascript
复制
casperjs test tests/tables.js --includes=tests/phantomcss-functions.js --post=tests/phantomcss-cleanup.js --pre=tests/phantomcss-setup.js

...produces...

代码语言:javascript
复制
Test file: tests/phantomcss-setup.js
Test file: tests/tables.js
Test file: tests/phantomcss-cleanup.js
PASS 1 test executed in 2.416s, 1 passed, 0 failed, 0 dubious, 0 skipped.

但是,当我试图在整个目录上运行CapserJS时,它并没有完全失败--只是不起作用,从--前一步跳到--post步骤,而不遍历目录中的任何文件:

代码语言:javascript
复制
Test file: tests/phantomcss-setup.js
Test file: tests/phantomcss-cleanup.js

不及格,不失败。就是这样。我完全不知所措。调试输出中没有任何内容。我已经包含了下面的脚本输出。如果有人知道下一步该做什么,我很想听听!

phantomcss-functions.js

代码语言:javascript
复制
var phantomcss = require('../node_modules/phantomcss/phantomcss.js');

function fileNameGetter(root,filename){ ... }

phantomcss.init({
    fileNameGetter: fileNameGetter
});

phantomcss-setup.js

代码语言:javascript
复制
casper.start();
casper.viewport(1024, 768);
casper.test.done();

phantomcss-cleanup.js

代码语言:javascript
复制
casper.then( function now_check_the_screenshots(){
    phantomcss.compareAll();
});
casper.then( function end_it(){
    casper.test.done();
});
casper.run(function(){
    phantom.exit(phantomcss.getExitStatus());
});

tables.js (测试文件示例)

代码语言:javascript
复制
casper.thenOpen( 'http://127.0.0.1:5000/prototypes/page-product-basic.html' );
casper.then(function(){
    phantomcss.screenshot('table.attribute-table:first-of-type', 'Table - Attribute');
});
casper.test.done();
EN

回答 1

Stack Overflow用户

发布于 2014-08-29 14:01:54

我需要研究为什么,但是看起来"test“文件不能与pre.post/include文件位于同一个目录中。一旦我将测试文件隔离到他们自己的" test“目录中,它就开始正常工作了。

我想,有时候你只需要问一个问题就能想出另一件事来尝试。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25569698

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档