9

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?

Haralan Dobrev
  • 7,617
  • 2
  • 48
  • 66
lesjames
  • 91
  • 4
  • I didn't catch this question when I was writing mine, but I realise we're after the same thing... (in case I get an answer and you found nothing): http://stackoverflow.com/questions/17467324/phantomjs-qunit-grunt-testing-browser-resize-widgets – creamcheese Jul 04 '13 at 10:00

2 Answers2

1

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!

Cybermaxs
  • 24,378
  • 8
  • 83
  • 112
1

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 }
      }
    }
  },
});
danvk
  • 15,863
  • 5
  • 72
  • 116