Skip to content

Commit e22959c

Browse files
committed
test: add test on considering null source content as mark to not skip reading
1 parent 0876dba commit e22959c

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

test/__snapshots__/loader.test.js.snap

+26
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,32 @@ Object {
334334

335335
exports[`source-map-loader should process inlined sources: warnings 1`] = `Array []`;
336336

337+
exports[`source-map-loader should process null in sources content: css 1`] = `
338+
"with SourceMap
339+
// comment
340+
"
341+
`;
342+
343+
exports[`source-map-loader should process null in sources content: errors 1`] = `Array []`;
344+
345+
exports[`source-map-loader should process null in sources content: map 1`] = `
346+
Object {
347+
"file": "null-in-sources-content.js",
348+
"mappings": "AAAA",
349+
"sources": Array [
350+
"/test/fixtures/null-in-sources-content.txt - (normalized for test)",
351+
],
352+
"sourcesContent": Array [
353+
"with SourceMap
354+
// comment
355+
",
356+
],
357+
"version": 3,
358+
}
359+
`;
360+
361+
exports[`source-map-loader should process null in sources content: warnings 1`] = `Array []`;
362+
337363
exports[`source-map-loader should process percent-encoding path: css 1`] = `
338364
"with SourceMap
339365
// comment
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
with SourceMap
2+
// #sourceMappingURL=null-in-sources-content.js.map
3+
// comment

test/fixtures/null-in-sources-content.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
with SourceMap
2+
// comment

test/loader.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,27 @@ describe("source-map-loader", () => {
107107
expect(getErrors(stats)).toMatchSnapshot("errors");
108108
});
109109

110+
it("should process null in sources content", async () => {
111+
const testId = "null-in-sources-content.js";
112+
const compiler = getCompiler(testId);
113+
const stats = await compile(compiler);
114+
const codeFromBundle = getCodeFromBundle(stats, compiler);
115+
const deps = stats.compilation.fileDependencies;
116+
117+
const dependencies = [
118+
path.resolve(__dirname, "fixtures", "null-in-sources-content.js.map"),
119+
];
120+
121+
dependencies.forEach((fixture) => {
122+
expect(deps.has(fixture)).toBe(true);
123+
});
124+
expect(codeFromBundle.map).toBeDefined();
125+
expect(normalizeMap(codeFromBundle.map)).toMatchSnapshot("map");
126+
expect(codeFromBundle.css).toMatchSnapshot("css");
127+
expect(getWarnings(stats)).toMatchSnapshot("warnings");
128+
expect(getErrors(stats)).toMatchSnapshot("errors");
129+
});
130+
110131
it("should reject http SourceMaps", async () => {
111132
const testId = "http-source-map.js";
112133
const compiler = getCompiler(testId);

0 commit comments

Comments
 (0)