-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: fix #50665 .skip
, .todo
and .only
missing in subtests
#50673
test_runner: fix #50665 .skip
, .todo
and .only
missing in subtests
#50673
Conversation
Review requested:
|
638b7b6
to
63fdacf
Compare
63fdacf
to
8834f4b
Compare
lib/internal/test_runner/test.js
Outdated
this.test = (name, options, fn) => { | ||
const overrides = { | ||
__proto__: null, | ||
loc: getCallerLocation(), | ||
}; | ||
// eslint-disable-next-line no-use-before-define | ||
const subtest = this.#test.createSubtest(Test, name, options, fn, overrides); | ||
return subtest.start(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be more performant to leave this as a prototype method, and instead do a public class field test = FunctionPrototypeBind(this.test, this);
, so that the "meat" of the method can be shared and optimized across all instances?
separately, couldn't the skip/todo/only methods be assigned to the prototype method once, in a static block, instead of a new function created on every instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean with Object.defineProperty, then without changing the #test
to [kTest]
it can't as it cannot access private method outside the class.
if you mean adding the skip/todo/any in the constructor but keeping the test function as is, than for some reason it did not work for me
The skip/todo/any methods are needed to assign on the test function, not on the TestContext
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, true, the 3 expandos need to be done in the constructor every time - altho the meat could be shared private methods and the per-instance thing could just be a bound function.
lib/internal/test_runner/test.js
Outdated
@@ -153,20 +178,6 @@ class TestContext { | |||
this.#test.todo(message); | |||
} | |||
|
|||
test(name, options, fn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not keep as prototype methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason it did not work for me adding skip/todo/etc to the test function
The docs for
How is that supposed to map to use of
Presumably this implements the first one (though I don't see any tests for that scenario). Either way the docs should be updated, because right now they imply that
|
Removed the
author ready
|
8834f4b
to
8ba986d
Compare
… subtests
8ba986d
to
77128c7
Compare
This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open. |
Closing this because it has stalled. Feel free to reopen if this issue/PR is still relevant, or to ping the collaborator who labelled it stalled if you have any questions. |
Fix #50665