| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8b70e6b commit 4f88179
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2573,6 +2573,12 @@ disconnected socket. | |||
| 2573 | 2573 | ||
| 2574 | 2574 | A call was made and the UDP subsystem was not running. | |
| 2575 | 2575 | ||
| 2576 | + <a id="ERR_SOURCE_MAP_MISSING_SOURCE"></a> | ||
| 2577 | + | ||
| 2578 | + ### `ERR_SOURCE_MAP_MISSING_SOURCE` | ||
| 2579 | + | ||
| 2580 | + A file imported from a source map was not found. | ||
| 2581 | + | ||
| 2576 | 2582 | <a id="ERR_SQLITE_ERROR"></a> | |
| 2577 | 2583 | ||
| 2578 | 2584 | ### `ERR_SQLITE_ERROR` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1704,6 +1704,7 @@ E('ERR_SOCKET_CONNECTION_TIMEOUT', | |||
| 1704 | 1704 | E('ERR_SOCKET_DGRAM_IS_CONNECTED', 'Already connected', Error); | |
| 1705 | 1705 | E('ERR_SOCKET_DGRAM_NOT_CONNECTED', 'Not connected', Error); | |
| 1706 | 1706 | E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running', Error); | |
| 1707 | + E('ERR_SOURCE_MAP_MISSING_SOURCE', `Cannot find '%s' imported from the source map for '%s'`, Error); | ||
| 1707 | 1708 | E('ERR_SRI_PARSE', | |
| 1708 | 1709 | 'Subresource Integrity string %j had an unexpected %j at position %d', | |
| 1709 | 1710 | SyntaxError); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,11 @@ const { tmpdir } = require('os'); | |||
| 30 | 30 | const { join, resolve, relative, matchesGlob } = require('path'); | |
| 31 | 31 | const { fileURLToPath } = require('internal/url'); | |
| 32 | 32 | const { kMappings, SourceMap } = require('internal/source_map/source_map'); | |
| 33 | + const { | ||
| 34 | + codes: { | ||
| 35 | + ERR_SOURCE_MAP_MISSING_SOURCE, | ||
| 36 | + }, | ||
| 37 | + } = require('internal/errors'); | ||
| 33 | 38 | const kCoverageFileRegex = /^coverage-(\d+)-(\d{13})-(\d+)\.json$/; | |
| 34 | 39 | const kIgnoreRegex = /\/\* node:coverage ignore next (?<count>\d+ )?\*\//; | |
| 35 | 40 | const kLineEndingRegex = /\r?\n$/u; | |
@@ -390,6 +395,9 @@ class TestCoverage { | |||
| 390 | 395 | ||
| 391 | 396 | newUrl ??= startEntry?.originalSource; | |
| 392 | 397 | const mappedLines = this.getLines(newUrl); | |
| 398 | + if (!mappedLines) { | ||
| 399 | + throw new ERR_SOURCE_MAP_MISSING_SOURCE(newUrl, url); | ||
| 400 | + } | ||
| 393 | 401 | const mappedStartOffset = this.entryToOffset(startEntry, mappedLines); | |
| 394 | 402 | const mappedEndOffset = this.entryToOffset(endEntry, mappedLines) + 1; | |
| 395 | 403 | for (let l = startEntry.originalLine; l <= endEntry.originalLine; l++) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ const { readdirSync } = require('node:fs'); | |||
| 6 | 6 | const { test } = require('node:test'); | |
| 7 | 7 | const fixtures = require('../common/fixtures'); | |
| 8 | 8 | const tmpdir = require('../common/tmpdir'); | |
| 9 | + const { pathToFileURL } = require('node:url'); | ||
| 9 | 10 | const skipIfNoInspector = { | |
| 10 | 11 | skip: !process.features.inspector ? 'inspector disabled' : false | |
| 11 | 12 | }; | |
@@ -320,6 +321,20 @@ test('coverage with source maps', skipIfNoInspector, () => { | |||
| 320 | 321 | assert.strictEqual(result.status, 1); | |
| 321 | 322 | }); | |
| 322 | 323 | ||
| 324 | + test('coverage with source maps missing sources', skipIfNoInspector, () => { | ||
| 325 | + const file = fixtures.path('test-runner', 'source-map-missing-sources', 'index.js'); | ||
| 326 | + const missing = fixtures.path('test-runner', 'source-map-missing-sources', 'nonexistent.js'); | ||
| 327 | + const result = spawnSync(process.execPath, [ | ||
| 328 | + '--test', | ||
| 329 | + '--experimental-test-coverage', | ||
| 330 | + file, | ||
| 331 | + ]); | ||
| 332 | + | ||
| 333 | + const error = `Cannot find '${pathToFileURL(missing)}' imported from the source map for '${pathToFileURL(file)}'`; | ||
| 334 | + assert(result.stdout.toString().includes(error)); | ||
| 335 | + assert.strictEqual(result.status, 1); | ||
| 336 | + }); | ||
| 337 | + | ||
| 323 | 338 | test('coverage with ESM hook - source irrelevant', skipIfNoInspector, () => { | |
| 324 | 339 | let report = [ | |
| 325 | 340 | '# start of coverage report', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments