-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Test runner should allow specific subtest filtering, via --test-name-pattern or otherwise #46728
Comments
I think we should be able to support this without any additional overhead other than the case where |
I'll take a look at this if nobody else has started on it. |
Hi guys, how about test on concated names? var describeNames = ['level1', 'level2'];
var itName = 'should pass'
var testNamePattern = /level1>level2>should pass/
testNamePattern.test([...describeNames,itName].join('>'))
// true I feel simpler and more reliable than inventing pattern syntax. |
I think |
All other runners that come to mind do filter both on |
I would expect |
I have checked, and these are the behaviors of other test runners:
this seems to be incorrect @connor4312
@cjihrig do you still expect that, given this information? |
That would still be my expectation, but I guess I would be wrong 😄. I'm fine with following the behavior of everyone else here. |
Jest certainly supports filtering by |
Ah, sorry, I misunderstood. |
Ok, so In regards to the comment made by @targos, I have tested this: describe("yes", function() {
it("no", () => {});
it("yes", () => {});
describe("maybe", function() {
it("no", () => {});
it("yes", () => {});
});
});
describe("no", function() {
it("no", () => {});
it("yes", () => {});
describe("maybe", function() {
it("no", () => {});
it("yes", () => {});
});
});
meaning |
Hello, I'm implementing a Node.js test runner integration in WebStorm. One of these common workflows involves running a special test from a file that contains multiple tests. debug-selected-test.movTo implement this workflow, it's essential to have the ability to configure a test runner to execute a specific test. Code ExampleLet's imagine that we have tests for callback and promise-based functionality (inspired by describe(`callback version`, () => {
test(`valid`, () => new Promise((resolve, reject) => {
validatePositiveNumber(1, (error, isValid) => {
try {
assert.ok(isValid);
resolve();
} catch (e) {
reject(e);
}
});
}));
// invalid, etc
});
describe(`promise based version`, () => {
test(`valid`, () =>
validatePositiveNumber(1)
.then(isValid => {
assert.ok(isValid);
})
);
// invalid, etc
}); Let's attempt to filter the
Can you please suggest a way to filter the The example in other tests runnersI checked the example in other test runners, and here are the results:
Suggestion to extend
|
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
@connor4312 @DmitryMakhnev I made a PR that I think directly addresses this issue 🤞🏼 |
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
Hello @mdrobny, Thank you so much for your contribution! I'm looking forward these fixes in next version of Node.js. Have a lovely time ✨ |
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
UpdateSo because this change is considered a breaking change, it will be released in Node.js 22 in April (if PR gets merged before that 😄 🤞🏼 ) |
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728
Thank you! I will eagerly adopt it as soon as possible 🙂 |
Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name Fixes: nodejs#46728 PR-URL: nodejs#51577 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Hello @mdrobny, |
Adopted for VS Code in connor4312/nodejs-testing@a490ae2, works great 👍 |
Version
19.3.0
Platform
Darwin MacBook-Pro-2.local 22.3.0 Darwin Kernel Version 22.3.0: Thu Jan 5 20:53:49 PST 2023; root:xnu-8792.81.2~2/RELEASE_X86_64 x86_64
Subsystem
test_runner
What steps will reproduce the bug?
Given a set of tests like this
... it is impossible to command line filter (
--test-name-filter
) to run only the "works" test inmy suite 2
.Being able to be precise about tests to run is important when working on an editor integration. If a user asks to "run this test", then only that test should run. This is especially relevant in the use case of integration tests, where running tests may have side effects.
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior?
I should be able to run
my suite 2 > works
by itself. In every test runner I've worked with (jest, mocha, or vitest for example) names are generated for glob purposes by space-delimiting nested tests. So I expected to be able to pass--test-name-pattern="^my suite 1 my suite 2 works$"
to run only that test.(This does mean that identically named tests in the same context cannot be differentiated. But this is a common problem across test runners that also affects result output, and I already have code that emits a diagnostic warning ('yellow squiggle') if the user does this.)
What do you see instead?
I must pass
--test-name-pattern="^my suite 1$" --test-name-pattern="^my suite 2$" --test-name-pattern="^works$"
, which runs the undesired test.Additional information
Apologies for the late followup on #42984. I didn't get a chance to work on the vscode integration for this for a few months, and only noticed this issue later.
The text was updated successfully, but these errors were encountered: