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

Allow for negation of patterns when using "-t" option #4452

Closed
4 tasks done
callmeberzerker opened this issue Nov 7, 2023 · 4 comments
Closed
4 tasks done

Allow for negation of patterns when using "-t" option #4452

callmeberzerker opened this issue Nov 7, 2023 · 4 comments

Comments

@callmeberzerker
Copy link

Clear and concise description of the problem

What I am trying to achieve is basically the following -> my unit tests don't have any addtional prefix (like some-service.test.ts) but my integration tests have int.test.ts prefix (like some-service.int.test.ts). I want to selectively run one or the other. See the scripts below to illustrate what I want to have. Basically the ability to exclude patterns from test.

        "test:unit": "vitest run -t .!(int).test.ts",
        "test:integration": "vitest run -t .int.test.ts",

Suggested solution

I have no particular suggested solution except maybe follow the Jest CLI regex in this regard? 🤔

Alternative

No response

Additional context

No response

Validations

@sheremet-va
Copy link
Member

  1. -t is a regexp
  2. -t is applied ONLY to test NAMES:
test('some name') // <-- this

@callmeberzerker
Copy link
Author

Ah gotcha. So can we add the possibility to add testPathPattern in conjunction with testPathIgnorePatterns (that Jest supports)? Here is from my enterprise project that uses Jest.

		"test:unit": "jest --testPathPattern=\\.test\\.ts$ -testPathIgnorePatterns=\\.int\\.test\\.ts$",
		"test:integration": "jest  --testPathPattern=\\.int\\.test\\.ts$",

@sheremet-va
Copy link
Member

Yes, it's named exclude and implemented in #4279

@callmeberzerker
Copy link
Author

Understood - closing!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants