由于Stack的其他许多人都在苦苦挣扎,我正在尝试将我的CasperJS测试拆分到多个文件中。我花了三天时间阅读文档,在这里搜索答案,似乎找不到任何有帮助的东西。
我有三个脚本(安装、函数、清理),其中包括使用--预、后和-包括命令。当我单独运行每个测试文件时,它工作得很好:
casperjs test tests/tables.js --includes=tests/phantomcss-functions.js --post=tests/phantomcss-cleanup.js --pre=tests/phantomcss-setup.js...produces...
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步骤,而不遍历目录中的任何文件:
Test file: tests/phantomcss-setup.js
Test file: tests/phantomcss-cleanup.js不及格,不失败。就是这样。我完全不知所措。调试输出中没有任何内容。我已经包含了下面的脚本输出。如果有人知道下一步该做什么,我很想听听!
phantomcss-functions.js
var phantomcss = require('../node_modules/phantomcss/phantomcss.js');
function fileNameGetter(root,filename){ ... }
phantomcss.init({
fileNameGetter: fileNameGetter
});phantomcss-setup.js
casper.start();
casper.viewport(1024, 768);
casper.test.done();phantomcss-cleanup.js
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 (测试文件示例)
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();发布于 2014-08-29 14:01:54
我需要研究为什么,但是看起来"test“文件不能与pre.post/include文件位于同一个目录中。一旦我将测试文件隔离到他们自己的" test“目录中,它就开始正常工作了。
我想,有时候你只需要问一个问题就能想出另一件事来尝试。
https://stackoverflow.com/questions/25569698
复制相似问题