Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting PhantomJS viewportSize in QUnit test

I need to test my script at different viewport sizes. In my tests I'd like to change the viewport size of PhantomJS by setting page.viewportSize. I'm running my tests through grunt-contrib-qunit and PhantomJS isn't accessible in my test code. Is there a way to gain access to it?

like image 749
lesjames Avatar asked May 14 '13 20:05

lesjames


2 Answers

It's not possible now on the dist version.

grunt-contrib-qunit depends on grunt-lib-phantomjs, which don't allow this feature. But, an interesting commit (6 days ago) from bdowling on github is available. For sure, this will help you.

You can get this commit by yourself end edit the qunit task to try it.

Patience, my young Padawan. Patience!

like image 70
Cybermaxs Avatar answered Oct 05 '22 11:10

Cybermaxs


It's possible to do this now. Here's what my Gruntfile.js looks like:

grunt.initConfig({
  pkg: grunt.file.readJSON('package.json'),
  qunit: {
    src: ['tests/test.html'],
    options: {
      page : {
        viewportSize : { width: 1280, height: 800 }
      }
    }
  },
});
like image 30
danvk Avatar answered Oct 05 '22 11:10

danvk