Is it possible to use the TestCafe .meta object to skip tests running from the cli

ぃ、小莉子 提交于 2021-01-27 12:11:55

问题


I'm using TestCafe to run my integration tests. I know it has the test.skip function, which is great for when I'm testing locally and want to skip a set of tests I don't need/want to run... but I was wondering if there was a way to run ALL TESTS except --test-meta environmentSpecific=true etc?

We have a number of different environments, and I'm looking for a simple way to skip tests via the CLI, depending on the environment we're targeting for the build.


回答1:


Yes, you can do it using the programmatic way to run TestCafe. See an example:

const createTestCafe = require('testcafe');
let testcafe         = null;

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe     = tc;
        const runner = testcafe.createRunner();

        return runner
            .src('/tests')
            .filter((testName, fixtureName, fixturePath, testMeta, fixtureMeta) => {
                 return !testMeta.environmentSpecific;
             })
            .browsers(['chrome', 'safari'])
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });


来源:https://stackoverflow.com/questions/55620995/is-it-possible-to-use-the-testcafe-meta-object-to-skip-tests-running-from-the-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!