Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup!: unbreak caller location
  • Loading branch information
JakobJingleheimer committed Apr 8, 2026
commit bc3b228840e707ca44f09398debe93f7b98029d8
41 changes: 34 additions & 7 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ class TestContext {
this.#test.todo(message);
}

#runTest(name, options, fn) {
#runTest(name, options, fn, loc) {
const overrides = {
__proto__: null,
loc: getCallerLocation(),
loc,
};

const { plan } = this.#test;
Expand All @@ -378,12 +378,39 @@ class TestContext {
return subtest.start();
}

test = ObjectAssign((...args) => this.#runTest(...args), {
// [1] `getCallerLocation` cannot be nested (that causes it to cite the nested location instead).

test = ObjectAssign((name, options, fn) => this.#runTest(
name,
options,
fn,
getCallerLocation(), // [1]
), {
__proto__: null,
expectFailure: (name, opts, fn) => this.#runTest(name, { __proto__: null, ...opts, expectFailure: true }, fn),
only: (name, opts, fn) => this.#runTest(name, { __proto__: null, ...opts, only: true }, fn),
skip: (name, opts, fn) => this.#runTest(name, { __proto__: null, ...opts, skip: true }, fn),
todo: (name, opts, fn) => this.#runTest(name, { __proto__: null, ...opts, todo: true }, fn),
expectFailure: (name, opts, fn) => this.#runTest(
name,
{ __proto__: null, ...opts, expectFailure: true },
fn,
getCallerLocation(), // [1]
),
only: (name, opts, fn) => this.#runTest(
name,
{ __proto__: null, ...opts, only: true },
fn,
getCallerLocation(), // [1]
),
skip: (name, opts, fn) => this.#runTest(
name,
{ __proto__: null, ...opts, skip: true },
fn,
getCallerLocation(), // [1]
),
todo: (name, opts, fn) => this.#runTest(
name,
{ __proto__: null, ...opts, todo: true },
fn,
getCallerLocation(), // [1]
),
});

before(fn, options) {
Expand Down
Loading