我正在使用Grunt运行我的响应式网站测试。 Grunt-contrib-jasmine正在使用PhantomJS来运行网页。我注意到默认视口宽度为400px。不过,我也想测试一下我的大屏幕行为。如何更改PhantomJS的视口宽度?
非常感谢。
我的Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
cssmin: {
css: {
src: 'css/common/page.css',
dest: 'css/common/page.min.css'
}
},
jshint: {
options: {
browser: true,
curly: true,
eqeqeq: true,
eqnull: true,
funcscope: true,
globals: {
jQuery: true
},
loopfunc: true,
reporter: require('jshint-stylish'),
smarttabs: true,
shadow: true
},
all: ['Gruntfile.js', 'js/default.j s', 'js/utils.js', 'tests/jasmine-standalone-2.0.0/spec/*.js']
},
jasmine: {
obpjs: {
src: 'tests/jasmine-standalone-2.0.0/src/*.js',
options: {
specs: 'tests/jasmine-standalone-2.0.0/spec/CommonSpec.js',
vendor: ['js/extlib.min.js', 'tests/jasmine-jquery/jasmine-jquery.js'],
helpers: ['js/utils.js', 'js/default.js'],
styles: 'css/common/page.min.css',
summary: true,
keepRunner: true
}
}
},
watch: {
script: {
files: ['js/default.js', 'js/utils.js'],
tasks: ['jshint']
},
styles: {
files: ['css/common/page.css'],
tasks: ['cssmin']
},
tests: {
files: ['js/default.js', 'js/utils.js', 'tests/jasmine-standalone-2.0.0/spec/*.js'],
tasks: ['jshint', 'jasmine']
}
}
});
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['jshint', 'jasmine']);
grunt.registerTask('build', ['cssmin', 'jshint', 'jasmine']);
};
答案 0 :(得分:3)
试试这个:
jasmine: {
obpjs: {
src: 'tests/jasmine-standalone-2.0.0/src/*.js',
options: {
specs: 'tests/jasmine-standalone-2.0.0/spec/CommonSpec.js',
vendor: ['js/extlib.min.js', 'tests/jasmine-jquery/jasmine-jquery.js'],
helpers: ['js/utils.js', 'js/default.js'],
styles: 'css/common/page.min.css',
summary: true,
keepRunner: true,
page: {
viewportSize: {
width: 480,
height: 800
}
}
}
}
}
http://phantomjs.org/api/webpage/property/viewport-size.html