问题
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