testinge2e-testingtestcasetestcafeparameterized-tests

How can I write parameterized tests with open source testcafe?


I found a lot of introductions to parameterized tests/ test cases for test cafe, but the syntax is completely different to the one I am using. I guess they're for the discontinued paid version. How can I do the same thing with the free version? I'm not looking for user roles specifically, I want to write tests with parameters in general.


Solution

  • Do you want to do something like this? This works for me perfectly

    import { Selector } from 'testcafe';
    
    fixture `Your fixture`
    .page `http://some_url.com`
    
    const testCases = [ 
        { name: 'name1', param: 'param1' },
        { name: 'name2', param: 'param2' }
        ...
    ];
    
    for (const c of testCases) {
        test(`Test ${c.name}`, async t => {
            yourTestMethod(c.param)
        });
    }