tests: update sourcemap tests for npm-only source existence check (#31601)

Update the sourcemap_nonexistent_source test expectation to reflect that
source file existence is only checked for npm packages (for
performance).

Add sourcemap_npm_nonexistent_source test to cover the npm package case
where source maps reference non-existent files and should fall back to
showing the bundle file path in stack traces.
This commit is contained in:
Felipe Cardozo 2025-12-15 19:21:01 -03:00 committed by GitHub
parent 783829a882
commit efea61e1bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 40 additions and 11 deletions

View file

@ -1,6 +1,14 @@
{
"ignore": true,
"args": "run bundle.js",
"output": "bundle.js.out",
"exitCode": 1
"tests": {
"node_modules": {
"args": "run --allow-read node_modules.ts",
"output": "node_modules.out",
"exitCode": 1
},
"not_node_modules": {
"args": "run not_node_modules.js",
"output": "not_node_modules.out",
"exitCode": 1
}
}
}

View file

@ -1 +0,0 @@
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,SAAS,UAAU;IACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACxD,CAAC;AAED,UAAU,EAAE,CAAC"}

View file

@ -1,5 +0,0 @@
error: Uncaught (in promise) Error: Test error from bundle with missing source
throw new Error("Test error from bundle with missing source");
^
at throwError ([WILDCARD]bundle.js:3:3)
at [WILDCARD]bundle.js:6:14

View file

@ -0,0 +1,3 @@
{
"nodeModulesDir": "manual"
}

View file

@ -0,0 +1,3 @@
error: Uncaught (in promise) Error: Test error from npm bundle with missing source
at throwError ([WILDCARD]node_modules/test-pkg/bundle.js:3:9)
at [WILDCARD]node_modules.ts:3:1

View file

@ -0,0 +1,3 @@
import { throwError } from "test-pkg";
throwError();

View file

@ -0,0 +1,8 @@
// Simulates an npm package bundle where source files don't exist
function throwError() {
throw new Error("Test error from npm bundle with missing source");
}
module.exports = { throwError };
//# sourceMappingURL=bundle.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,SAAS,UAAU;IACjB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;AAChE,CAAC;AAED,OAAO,CAAC,OAAO,GAAG,EAAE,UAAU,EAAE,CAAC"}

View file

@ -0,0 +1,5 @@
{
"name": "test-pkg",
"version": "1.0.0",
"main": "bundle.js"
}

View file

@ -5,4 +5,4 @@ function throwError() {
throwError();
//# sourceMappingURL=bundle.js.map
//# sourceMappingURL=not_node_modules.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"not_node_modules.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,SAAS,UAAU;IACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACxD,CAAC;AAED,UAAU,EAAE,CAAC"}

View file

@ -0,0 +1,3 @@
error: Uncaught (in promise) Error: Test error from bundle with missing source
at throwError ([WILDCARD]src/index.ts:3:3)
at [WILDCARD]src/index.ts:6:14