testingautomated-testse2e-testingtestcafetest-runner

How i can to customize testRunner from testcafe framework?


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();

Solution

  • 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