There are lots of situations when we need to run only some of our automated tests instead of the whole test suite (e.g. run only the smoke tests instead of the full regression suite; the entire suite grows and you might want to run only subsets of your tests, and so on).
This thing is possible in TestCafe using the metadata filters.
How do we apply this approach?
Step 1 – Include meta in your test or fixture (key-value pairs, e.g. .meta(‘type’, ‘smoke’))
Personal use case: I used this approach for filtering tests using meta tags by ‘smoke’ and ‘regression’ values. On DEV environments I want to run only the tests marked with ‘smoke’ tag, and on STG environment I want to run all the tests (marked with ‘regression’ meta).
In the following test file, I included .meta(‘type’,’smoke’) in the title of test2 and test3, and .meta(‘type’,’regression’) for test 4.

Step 2 – Run the tests from CLI, using the --test-meta type=smoke flag. The test execution will
include only the tests that contain this meta tag value (e.g. test2 and test3).

Note: you can add meta on fixtures (test suites) as well, not only on individual tests. More information HERE
If you liked this article, then please subscribe to my YouTube Channel for Test Automation video tutorials. You can also find me on LinkedIn and Twitter.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.