diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 635520783dad9a..80af0f9d978637 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -14,6 +14,7 @@ const { PromisePrototypeThen, PromiseResolve, SafePromisePrototypeFinally, + StringPrototypeStartsWith, StringPrototypeTrim, ReflectApply, RegExpPrototypeExec, @@ -58,6 +59,7 @@ const { } = require('internal/validators'); const { setTimeout } = require('timers'); const { TIMEOUT_MAX } = require('internal/timers'); +const { fileURLToPath } = require('internal/url'); const { availableParallelism } = require('os'); const { bigint: hrtime } = process.hrtime; const kCallbackAndPromisePresent = 'callbackAndPromisePresent'; @@ -383,6 +385,10 @@ class Test extends AsyncResource { this.loc.file = entry.originalSource; } } + + if (StringPrototypeStartsWith(this.loc.file, 'file://')) { + this.loc.file = fileURLToPath(this.loc.file); + } } } diff --git a/test/fixtures/test-runner/output/source_mapped_locations.snapshot b/test/fixtures/test-runner/output/source_mapped_locations.snapshot index c7baee728d0218..24c3ee8d113446 100644 --- a/test/fixtures/test-runner/output/source_mapped_locations.snapshot +++ b/test/fixtures/test-runner/output/source_mapped_locations.snapshot @@ -3,7 +3,7 @@ TAP version 13 not ok 1 - fails --- duration_ms: * - location: 'file:///test/fixtures/test-runner/output/source_mapped_locations.ts:5:1' + location: '/test/fixtures/test-runner/output/source_mapped_locations.ts:5:1' failureType: 'testCodeFailure' error: |- Expected values to be strictly equal: