← Back to Discord Forum

Run tests based on description

Is it possible to run a group of tests based on description block for example, I have a description block that looks like this: test.describe('dashboard smoke tests', () => {

Can I do npx playwright test -g "dashboard smoke tests"

This thread is trying to answer question "Is it possible to run a group of tests based on a description block?"

3 replies

seems to work for me added/moving my tests in a describe block worked for me.

I would recommend using a tag instead of using the entire describe block. Using @Smoke versus the describe block allows you to be more descriptive in the describe block as well as it is a smaller search pattern.


This is an article I wrote up on my experience with running subset of tests 🙂 https://playwrightsolutions.com/run-a-subset-of-tests-with-grep-and-grep-invert-in-package-json/


Sure, you can group your tests using the test.describe() command in @playwright/test. This function allows you to declare a group of tests with a specific title and callback function. Any tests added within this callback will belong to the group.

Here's how you can do it:

test.describe('Feature A', () => {
  test('Test case 1', async ({ page }) => {
    // Test logic for Test case 1

  test('Test case 2', async ({ page }) => {
    // Test logic for Test case 2

  // Add more test cases...

In this example, we've created a description block titled "Feature A". Inside this block, we've added two test cases. You can add as many test cases as you need within the description block.

Grouping your tests based on their descriptions makes it easier to manage and execute specific sets of tests. You can selectively run all the tests within a particular description block by running that specific group. This can be a great way to organize your tests, especially when dealing with larger test suites.

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.