0

I'm actually trying to use a test-runner file to figure out all my configs from this file. I'm using tests for Smoke and Regression scripts. So, i want my tests to run based on Smoke or Functional test metadata that i choose from the tet runner file. The filter works when i give in package.json file. But it is not working in test runner file using runner.filter

Kindly, help if someone knows the reason.

Below is the snippet from Test.js file,

test.meta('smokeTest','true)('Testing application as admin', async t=> {
await t.click(elements.submitButton);
})

Whereas the test-runner file is,

const createTestCafe = require('testcafe');

try {
    const runner = testcafe.createRunner();

    const failedCount = await runner
        .src('./tests/fixture1.js')
        .filter(testMeta => {return testMeta.smokeTest === 'true';})
        .browsers('chrome')
        .run();

    console.log('Tests failed: ' + failedCount);
}
finally {
    await testcafe.close();
}

The filter works when we run it from command line like,

testcafe chrome ./tests/fixture1.js --test-meta smokeTest=true

When I used the test-runner file, it says the filter settings has excluded all the tests, try to modify the settings

  • We will be happy to help you and diagnose this problem, However, I didn't manage to reproduce it. Submit a bug report here: [https://github.com/DevExpress/testcafe/issues/new?assignees=&labels=&template=bug-report.md](https://github.com/DevExpress/testcafe/issues/new?assignees=&labels=&template=bug-report.md) And add your environment information there, as well as a sample project and tests, so that we can suggest a solution for you – Viktoriya Chernookaya May 18 '21 at 12:40
  • I just updated the snippets in the description and the error i faced. Let me know the possible solution please. – Saly Subitsha May 19 '21 at 06:40

1 Answers1

1

According to the documentation, you need to specify your filter callback arguments in the following way: function(testName, fixtureName, fixturePath, testMeta, fixtureMeta). Your .filter should be rewritten as follows:

.filter((testName, fixtureName, fixturePath, testMeta, fixtureMeta) => testMeta.smokeTest === 'true')
Vladimir A.
  • 2,202
  • 2
  • 10
  • 28