Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: --grep when using regex appears broken. #30896

Closed
ZooDoo4U opened this issue May 18, 2024 · 2 comments
Closed

[Bug]: --grep when using regex appears broken. #30896

ZooDoo4U opened this issue May 18, 2024 · 2 comments

Comments

@ZooDoo4U
Copy link

Version

1.44.0

Steps to reproduce

  1. In VS Code with the PW Plugin installed., Create/open an empty folder.

  2. VS Codes command pallet and Install: Playwright

  3. Look at Test Explorer, ensure the stock sample project was installed, should see in the test explorer "get started link"

  4. open the terminal in VS Code and run, first few work then...

  5. npx playwright test "get started link"
    Running 1 test using 1 worker
    [1/1] [firefox] › example.spec.ts:10:5 › get started link
    (works as expected.)

  6. npx playwright test --grep "get.+link"
    [1/1] [firefox] › example.spec.ts:10:5 › get started link
    (works as expected.)

-- Note the regex for begins with and ends with...
8. npx playwright test --grep "^get.+link$"
No tests found.

Expected behavior

the last command example in the repro steps should have worked...

Actual behavior

No tests are run when adding in regex meta characters for begins with it seems.

Additional context

none -- should be really straight forward...

other than help has no docs on the "Flavor of regex" if unqualified all regex commands should be valid as is, and shouldn't be language specific. Such as javascript might requires like the '//ig' regex command format. If required "internal" then one shouldn't need to enter them on the command line if always needed the plug in should add them...? So:
npx playwright test --grep "/<>/ig" seems unnecessary if --grep has already been entered?

On other note, it seems this is related to when tag annotations, i swear i use to have batch files for running test and --grep worked exactly as expected, not running them for a while i might bet the issue came in with overloading grep with tags. Honestly it seem there should be a --grep only for tests titles, and --grepTag for searching tags and the two, however fancy one is trying to be, they should be completely separate. What if i have s collision of a test title that might pick up tests with the tag but wish only one to run... With the test title and tags searched, not sure how to get so only one will run, or not include something not desired to run... But i'd agree a separate issue, but just feels to me the grep functionality broke with the 'tag functionality...' So kind of related and something to consider this when fixing this...?

Finally would assert any regex that works when references www.regex101.com if it matches then it should work...

Environment

Win 10 
{
  "name": "sample",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {},
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@playwright/test": "^1.44.0",
    "@types/node": "^20.12.12"
  }
@marshmn
Copy link
Contributor

marshmn commented May 18, 2024

This issue may be related to the confusion caused by #30895

Both of these issues originated from the same Discord thread: https://discord.com/channels/807756831384403968/1241331291425869844

One thing to note is that regardless of whether this is an "issue" as such or not, it does create some awkward behaviour, since it's not possible to easily use grep to match on a full test name.

For example, if you have two tests:

  • "foo"
  • "foo bar"

If you only want to match the first one, you can't match on ^foo$ since that doesn't work - you'd have to include project name, file name, test name and tags - which is somewhat painful.

@pavelfeldman
Copy link
Member

Folding into #30895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants