-
Notifications
You must be signed in to change notification settings - Fork 124
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
add exactTestName option #282
base: master
Are you sure you want to change the base?
Conversation
can we merge this before the PR has its 1. birthday? :) would like to have this feature as well.
Exactly, you should consider to make exact the default option. |
@domsleee what do you think? |
I think it's a good idea and can be made default at some point, but imo it should be an experimental flag for now. I was testing it with the "Extension examples" build: There's a problem with this example: describe('nested', () => {
describe('a', () => {
it('b', () => {
expect(true);
});
});
}); So if you click run on anything other than the inner-most block ( For example, pressing node "node_modules/jest/bin/jest.js" "c:/Users/user/git/vscode-jest-runner/examples/examples.test.ts" -t "^nested a$" So we could check that it is the inner most block during parsing in JestRunnerCodeLensProvider. There is also this case to consider - note that the parser only sees the describe block here: describe('tests', () => {
generateTest('mytest');
});
function generateTest(name: string) {
it(name, () => {
expect(true);
});
} When you press run on the describe block, it should run So what I'm thinking is - maybe the exact matching should only be on It might be an idea to the parsedNode type of the CodeLens, and then retrieve it later (the condition would be vscode-jest-runner/src/JestRunnerCodeLensProvider.ts Lines 47 to 51 in ad3d16a
Thoughts? |
my thoughts: genereally the test name hierarchy for the regex can be quite specific? Indroducing this option will possibly introduce new issues as @domsleee just showed. Maybe enabling it only for the "it" block will solve it? but still you have the problem with nested it's.. We should not merge this, till we found a solution for this questions. best regards |
I was about to create pretty much the same MR right now. Can we merge this by renaming |
Background
Hi 👋 Power-user and big fan of the extension!
I often run into the issue of overlapping test names.
e.g. One test called "do something" and another called "do something else"; Running the first test using vscode-jest-runner will run both tests. This is because Jest's
-t
option regex matches. Most of the time I'd like to run the single exact test name. In the off chance I'm looking to run multiple tests, I could still go into the terminal and edit the command, but in 95% of cases I'm looking for one test and can be confused when an unexpected output is shown (until I realize multiple tests are running).Changes
exactTestName
boolean config option^
$
for an exact regex matchpackage.json
README.md
FYI: I have verified that the wrapping works in my terminal, by manually replaying a generated terminal command from vscode-jest-runner and adding the characters — but, I haven't built the extension and tested end-to-end.