How can I set the viewport size of PhantomJS through grunt & jasmine?

此生再无相见时 提交于 2019-12-10 00:23:30

问题


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.

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 : {},
  ...
});

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

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

回答1:


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
      }
    },
  ...
}


来源:https://stackoverflow.com/questions/22613709/how-can-i-set-the-viewport-size-of-phantomjs-through-grunt-jasmine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!