如何设置视口大小的PhantomJS通过grunt&茉莉花? [英] How can I set the viewport size of PhantomJS through grunt & jasmine?

查看:519
本文介绍了如何设置视口大小的PhantomJS通过grunt&茉莉花?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用grunt + jasmine + phantomjs测试一下。

I'm trying to test something using grunt + jasmine + phantomjs. This specific test requires a large viewport so the responsive styles render the large-screen version within phantomjs.

我在 grunt-contrib-jasmine中注意到了这个特殊的测试需要一个大的视口,所以响应式的风格会渲染phantomjs中的大屏幕版本。 插入此代码,这似乎允许设置phantomjs选项:

I noticed in the grunt-contrib-jasmine plugin this code, which would seem to allow for setting phantomjs options:

// Merge task-specific options with these defaults.
var options = this.options({
  ...
  phantomjs : {},
  ...
});

b
$ b

However, when I add this to my config in grunt it has no effect:

options: {
  phantomjs: {
    viewportSize: {
      width: 2000,
      height: 1000
    }
  }
}


推荐答案

答案在于 viewportSize 页面对象的选项,而不是phantomjs。 grunt config需要如下所示:

The answer lies in the fact that viewportSize is an option for the page object, not phantomjs. The grunt config needs to look like this:

taskName: {
  options: {
    page: {
      viewportSize: {
        width: 2000,
        height: 800
      }
    },
  ...
}

这篇关于如何设置视口大小的PhantomJS通过grunt&茉莉花?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆