PhantomJS, Qunit, Grunt testing browser resize widgets

廉价感情. 提交于 2019-12-11 08:25:13

问题


I've created a jQuery UI Widget that resizes a DIV/thing to fill up the browser screen. It all works fine but now I want to create unit tests for testing that it's resizing and keeping to boundaries etc.

I'm using Grunt with grunt-contrib-qunit, which uses PhantomJS to do tests but am now unsure how I can test browser resizing at this point as it's not possible via JS to resize a browser. Perhaps PhantomJS provides something that allows me to alter it at runtime?


回答1:


Check CasperJS library. It allows you to control "browser" (which is PhantomJS actually).




回答2:


You can use the following code to define the width and height of the chrome-less browser:

grunt.initConfig({
   qunit: {
      src: ['tests/test.html'],
      options: {
          page : {
              viewportSize : { width: 1280, height: 800 }
          }
      }
   },
});


来源:https://stackoverflow.com/questions/17467324/phantomjs-qunit-grunt-testing-browser-resize-widgets

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