3
I have my testRunner for tests.
But the problem is -> how i can add the browser resolution in test 

runner, because i don't want to add this to my tests. Thanks for help.

      runner
        .src(testFiles)
        .browsers('chrome')
        .reporter('html', stream)
        .run()
        .then(failedCount => {
          console.log(failedCount);
          testcafe.close();
Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Lev Boichenko
  • 497
  • 1
  • 5
  • 9

1 Answers1

3

You can manage the resolution of your browser via cmd parameters. Since Chrome supports --window-size parameter you can pass it to the .browsers method of your runner. Please see the following example:

const createTestCafe = require('testcafe');
let testcafe         = null;

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe     = tc;
        const runner = testcafe.createRunner();

        return runner
            .src('my-tests.js')
            .browsers(['chrome --window-size=1000,500', 'chrome --window-size=500,200'])
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });

Here I run tests in two Chrome instances but with different window sizes

Please also refer to the following article https://devexpress.github.io/testcafe/documentation/using-testcafe/programming-interface/runner.html#browsers to see different ways of using the .browsers method

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Alex Kamaev
  • 6,198
  • 1
  • 14
  • 29