【问题标题】:How to specify only tests with specific meta tag如何仅指定具有特定元标记的测试
【发布时间】:2019-07-16 17:07:40
【问题描述】:

我有一个使用元标记的测试套件,我正在尝试运行特定的测试。

我尝试过使用以下方法:

  .filter((fixturePath, fixtureName, testMeta) => {
    return testMeta.smoke == 'true';
  })

runner.ts

const createTestCafe = require('testcafe'); let testcafe = null; createTestCafe('localhost', 1337, 1338) .then((tc) => { testcafe = tc; const runner = testcafe.createRunner(); return runner .src(['tests/specs/**/*.spec.ts']) .filter((fixturePath, fixtureName, testMeta) => { return testMeta.smoke == 'true'; }) .browsers(['chrome']) .reporter([ 'list' ]) .run(); }) .then((failedCount) => { console.log('Tests failed: ' + failedCount); testcafe.close(); });

示例测试

test('Login with correct credentials', async (t) => { await LoginPage.login(data.users.userPrivate.username, data.users.userPrivate.password); await t.expect(Helper.getLocation()).contains(endpoints.personalAreaOverview); }).meta('regression', 'true').meta('smoke', 'true');

预期:仅使用 ('smoke', 'true') 运行测试

实际:Error: No tests to run. Either the test files contain no tests or the filter function is too restrictive.

【问题讨论】:

    标签: node.js typescript testing automated-tests testcafe


    【解决方案1】:

    filter 方法有另一个参数顺序。您需要按如下方式更改代码:

    runner.ts

    .filter((testName, fixtureName, fixturePath, testMeta, fixtureMeta) => {
        return testMeta.smoke === 'true';
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-23
      • 2012-01-03
      • 1970-01-01
      相关资源
      最近更新 更多