Search code examples
testingautomated-testse2e-testingweb-testingtestcafe

Quarantine mode for the fixture or test


Is it possible to run some tests in quarantine mode and run others without the mode? For example, we have some lightweight tests and we don't need 3 tries for them, but for others it can be necessary


Solution

  • You can run two testcafe runners in series with different filters. One of them may be with the quarantine mode.

    For example:

    const createTestCafe = require('testcafe');
    
    let testcafe = null;
    
    const runTests = (testFiles, quarantineMode, testPrefix) => {
        const runner = testcafe.createRunner();
        return runner
            .src(testFiles)
            .filter((testName) => testName.startsWith(testPrefix))
            .browsers(['chrome'])
            .run({ quarantineMode });
    };
    
    createTestCafe('localhost', 1337, 1338)
        .then(tc => {
            testcafe = tc;
            return runTests(['test.js'], false, 'Simple')
                .then(() => runTests(['test.js'], true, 'Complex'));
        })
        .then(() => testcafe.close());
    

    tests:

    test('Simple Test', async t => {
        //...
    });
    
    test('Complex Test', async t => {
        //...
    });