Setting PhantomJS viewportSize in QUnit test
Asked Answered
A

2

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?

Apologize answered 14/5, 2013 at 20:32 Comment(1)
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): #17467824Velate
O
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!

Outcurve answered 17/12, 2013 at 21:18 Comment(0)
N
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 }
      }
    }
  },
});
Nels answered 28/8, 2014 at 23:30 Comment(1)
I can't find this documented anywhere, but it works! Thanks.Teshatesla

© 2022 - 2024 — McMap. All rights reserved.