【问题标题】:Is it possible to use the TestCafe .meta object to skip tests running from the cli是否可以使用 TestCafe .meta 对象跳过从 cli 运行的测试
【发布时间】:2019-09-01 09:51:22
【问题描述】:

我正在使用 TestCafe 运行我的集成测试。我知道它具有test.skip 功能,这对于我在本地进行测试并想跳过一组我不需要/不想运行的测试时非常有用......但我想知道是否有办法运行所有测试,除了 --test-meta environmentSpecific=true 等?

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

【问题讨论】:

    标签: automated-tests metadata e2e-testing web-testing testcafe


    【解决方案1】:

    是的,您可以使用编程方式运行 TestCafe。 看一个例子:

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

    另请参阅:Specify Test Metadata

    【讨论】:

      【解决方案2】:

      我无法发表评论,因为我没有 50 个代表...

      @mlosev 您将如何像在 runner 中那样过滤 .testcaferc.json 文件?

      我想运行所有测试,除了带有 toDo 元数据的测试:'yes'。当前配置文件:

      {
          "assertionTimeout": 5000,
          "browsers": ["chrome --window-size=1920,1159"],
          "concurrency": 7,
          "pageLoadTimeout": 15000,
          "reporter": {
              "name": "spec",
              "output": "artifacts/reports/test_suite_results"
          },
          "screenshots": {
              "path": "artifacts/screenshots",
              "pathPattern": "${TEST}_${DATE}_${TIME}.png",
              "takeOnFails": true
          },
          "selectorTimeout": 5000,
          "skipJsErrors": false,
          "src": "tests",
          "videoEncodingOptions": {
              "aspect": "16:9",
              "framerate": 30
          },
          "videoOptions": {
              "failedOnly": true,
              "pathPattern": "${TEST}_${DATE}_${TIME}.mp4",
              "singleFile": false
          }, 
          "videoPath": "artifacts/recordings"
      }
      

      【讨论】:

      • @mlosev,在评论中标记您,因为它不会在答案中标记用户。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      相关资源
      最近更新 更多