Skip to content

Commit 638b7b6

Browse files
committed
test_runner: fix #50665 .skip, .todo and .only missing in subtests
1 parent 83e6350 commit 638b7b6

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

lib/internal/test_runner/test.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
ArrayPrototypeShift,
77
ArrayPrototypeSlice,
88
ArrayPrototypeSome,
9+
ArrayPrototypeForEach,
910
ArrayPrototypeUnshift,
1011
FunctionPrototype,
1112
MathMax,
@@ -153,18 +154,32 @@ class TestContext {
153154
this.#test.todo(message);
154155
}
155156

156-
test(name, options, fn) {
157-
const overrides = {
158-
__proto__: null,
159-
loc: getCallerLocation(),
157+
get test() {
158+
const testCreator = (name, options, fn) => {
159+
const overrides = {
160+
__proto__: null,
161+
loc: getCallerLocation(),
162+
};
163+
// eslint-disable-next-line no-use-before-define
164+
const subtest = this.#test.createSubtest(Test, name, options, fn, overrides);
165+
return subtest.start();
160166
};
161167

162-
const subtest = this.#test.createSubtest(
163-
// eslint-disable-next-line no-use-before-define
164-
Test, name, options, fn, overrides,
165-
);
168+
ArrayPrototypeForEach(['skip', 'todo', 'only'], (keyword) => {
169+
testCreator[keyword] = (name, options, fn) => {
170+
const overrides = {
171+
__proto__: null,
172+
[keyword]: true,
173+
loc: getCallerLocation(),
174+
};
175+
176+
// eslint-disable-next-line no-use-before-define
177+
const subtest = this.#test.createSubtest(Test, name, options, fn, overrides);
178+
return subtest.start();
179+
};
180+
});
166181

167-
return subtest.start();
182+
return testCreator;
168183
}
169184

170185
before(fn, options) {

0 commit comments

Comments
 (0)