首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >测试phantomCSS找不到ResembleJs容器

测试phantomCSS找不到ResembleJs容器
EN

Stack Overflow用户
提问于 2014-03-18 09:26:29
回答 4查看 1.2K关注 0票数 2

我试图将可视化比较测试添加到我的布局中,但是我似乎没有正确地配置我的测试环境。

我在用:

这是我的测试JS文件:

代码语言:javascript
复制
var url, screenshotRoot, modules, phantomCSS, page;

url             = 'http://website.local';
screenshotRoot  = 'tests/screenshots';
modules         = '../node_modules';
phantomCSS      = require(modules + '/phantomcss/phantomcss.js');
page            = { width: 1024, height: 768 };

phantomCSS.init({
    screenshotRoot: screenshotRoot,
    failedComparisonsRoot: screenshotRoot + '/failures',
    libraryRoot: modules + '/phantomcss',
});

casper
.start(url)
.then(function() {
    phantomCSS.screenshot("body", "elements-cheatsheet");
})
.then(function() {
    phantomCSS.compareAll();
})
.run(function() {
    phantom.exit(phantomCSS.getExitStatus());
});

casper.viewport(page.width, page.height);

当我运行casperjs test tests/layout.js时,测试开始,创建屏幕截图并抛出一个错误:

代码语言:javascript
复制
[PhantomCSS] Can't find Resemble container. Perhaps the library root is mis configured. (../node_modules/phantomcss/ResembleJs/resemblejscontainer.html)

我检查了resemblejscontainer.html文件的位置,它正好在抛出的错误中列出的位置。

我哪里错了?

EN

回答 4

Stack Overflow用户

发布于 2015-01-15 21:58:17

我想您希望能够在node_moduleslibbower_components之间进行更改。

下列工作也应有效:

代码语言:javascript
复制
modules = 'node_modules';
phantomCSS = require('./../' + modules + '/phantomcss/phantomcss.js');
…
phantomCSS.init({
    …
    libraryRoot: './' + modules + '/phantomcss'
});

(这是基于PhantomJS食谱的食谱。)

票数 2
EN

Stack Overflow用户

发布于 2014-03-18 10:05:55

使用绝对路径解决了我的问题:

代码语言:javascript
复制
modules = '/Users/username/path/node_modules';
票数 1
EN

Stack Overflow用户

发布于 2016-03-29 19:58:03

我在PhantomCSS文件夹中做了“sudo安装类似it”的工作。也许这比更改根文件夹或像我这样的新手用户的任何其他文件更容易。

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

https://stackoverflow.com/questions/22475061

复制
相关文章

相似问题

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