Как я могу настроить testRunner из фреймворка testcafe?

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

runner, потому что я не хочу добавлять это в свои тесты. Спасибо за помощь.

      runner
        .src(testFiles)
        .browsers('chrome')
        .reporter('html', stream)
        .run()
        .then(failedCount => {
          console.log(failedCount);
          testcafe.close();

person Lev Boichenko    schedule 24.01.2019    source источник


Ответы (1)


Вы можете управлять разрешением вашего браузера через параметры cmd. Поскольку Chrome поддерживает параметр --window-size, вы можете передать его в . браузеры вашего бегуна. См. Следующий пример:

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

Здесь я провожу тесты в двух экземплярах Chrome, но с разными размерами окон.

См. Также следующую статью https://devexpress.github.io/testcafe/documentation/using-testcafe/programming-interface/runner.html#browsers, чтобы узнать о различных способах использования метода .browsers.

person Alex Kamaev    schedule 24.01.2019