Rayrun
← Back to Discord Forum

Using grep

I'm facing an issue where grep return 0 test when used inside a github action.

If I use npx playwright test all my test are running.

If I use npx playwright test --grep @L1 it fails, even if I have a test like :

test("I have access to the homepage @L1",   async ({ page }) => {
  [...]
});

So to resume:

Locally: npx playwright testnpx playwright test --grep @L1

In github action: npx playwright testnpx playwright test --grep @L1 ❌ (Error: No tests found)

This thread is trying to answer question "Why does grep return 0 tests when used inside a GitHub action and how can it be resolved?"

1 reply

Solved, somehow have to escape the @ when using the github pipeline like: npx playwright test --grep \@L1

Answer

Troubleshooting 'grep' in GitHub Actions with Playwright

If you're using 'grep' in your GitHub Actions with @playwright/test and it's returning 0 tests, even though it works locally, there could be a few reasons why.

Check Your Configuration

First, make sure your 'grep' option is correctly configured in your GitHub Actions workflow file. This file should include steps for setting up and running Playwright tests, and specifying the 'grep' option with the right regular expressions.

// Example of a GitHub Actions workflow file
name: CI
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: microsoft/playwright-github-action@v1
    - name: Test
      run: npx playwright test --grep "your-regex-here"

Review Your Test Titles

Second, your Playwright tests should have suitable titles that match with the 'grep' option. If none of your test titles match the specified regular expressions, then 'grep' won't return any tests.

// Example of a Playwright test with a descriptive title
test('loads the homepage', async ({ page }) => {
  await page.goto('https://ray.run');
  // other test steps...
});

Consider Environment Differences

Lastly, there might be differences between running Playwright locally versus within a GitHub Action environment. Certain environment variables or configurations might affect how Playwright executes the 'grep' option within GitHub Actions.

Troubleshooting

To troubleshoot further, examine any error messages or logs generated during the execution of your GitHub Actions workflow. These logs may provide insights into why no tests are being returned when using 'grep'.

For more help, refer to the official Playwright documentation or online communities dedicated to Playwright or GitHub Actions.

Related Discord Threads

TwitterGitHubLinkedIn
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 [email protected].