mardi 16 juillet 2019

How to specify only tests with specific meta tag

I have a test suite using meta tags and I'm trying to run specific tests.

I've tried using the following method:

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

example test

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');

Expected: Run only the tests with ('smoke', 'true')

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

Aucun commentaire:

Enregistrer un commentaire