Skip to content

Commit

Permalink
test_runner: fix #50665 .skip, .todo and .only missing in subtests
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton committed Nov 11, 2023
1 parent 83e6350 commit 638b7b6
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
ArrayPrototypeShift,
ArrayPrototypeSlice,
ArrayPrototypeSome,
ArrayPrototypeForEach,
ArrayPrototypeUnshift,
FunctionPrototype,
MathMax,
Expand Down Expand Up @@ -153,18 +154,32 @@ class TestContext {
this.#test.todo(message);
}

test(name, options, fn) {
const overrides = {
__proto__: null,
loc: getCallerLocation(),
get test() {
const testCreator = (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();
};

const subtest = this.#test.createSubtest(
// eslint-disable-next-line no-use-before-define
Test, name, options, fn, overrides,
);
ArrayPrototypeForEach(['skip', 'todo', 'only'], (keyword) => {
testCreator[keyword] = (name, options, fn) => {
const overrides = {
__proto__: null,
[keyword]: true,
loc: getCallerLocation(),
};

// eslint-disable-next-line no-use-before-define
const subtest = this.#test.createSubtest(Test, name, options, fn, overrides);
return subtest.start();
};
});

return subtest.start();
return testCreator;
}

before(fn, options) {
Expand Down

0 comments on commit 638b7b6

Please sign in to comment.