是否可以使用TestCafe .meta对象跳过从cli运行的测试 [英] Is it possible to use the TestCafe .meta object to skip tests running from the cli

查看:54
本文介绍了是否可以使用TestCafe .meta对象跳过从cli运行的测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TestCafe来运行集成测试.我知道它具有 test.skip 函数,该函数非常适合当我在本地进行测试并且想要跳过不需要/不想运行的一组测试...但是我当时想知道是否有一种方法可以运行除 -test-meta environmentSpecific = true 等以外的所有测试?

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?

我们有许多不同的环境,我正在寻找一种简单的方法来通过CLI跳过测试,具体取决于我们针对构建的目标环境.

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.

推荐答案

是的,您可以使用编程方式来运行TestCafe.查看示例:

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

另请参阅:指定测试元数据

这篇关于是否可以使用TestCafe .meta对象跳过从cli运行的测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆