testingtestcafe

How to repeat in TestCafeStudio?


I want to repeat flow in testcafestudio.

How can I run 10~1000 times 1flow?

Here are two things I want to know this for:

  1. Run a page overload test
  2. Run 100 times on the same page

It seems there is no way to repeat the flow in testcafestudio, but I need to do this so I can repeat tests.


Solution

  • You can repeat a test multiple times in JavaScript test file format (https://docs.devexpress.com/TestCafeStudio/401052/test-concepts/test-scripts). It is also possible to record tests in JavaScript test file format.

    The following workaround allows you to repeat a test multiple times:

    import from 'testcafe';
    
    function testWrapper (name, cb, repeat = 5) {
        for (let index = 0; index < repeat; index++)
            test(name, cb);
    }
    
    fixture('Getting Started')
        .page('https://devexpress.github.io/testcafe/example');
    
    testWrapper('My first test', async t => {
        await t
            .typeText('#developer-name', 'John Smith')
            .click('#submit-button')
            .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
    });

    If you run your tests in codeless mode, you can do the same - just convert your test to JavaScript first.