Skip to content

Commit

Permalink
test: test with blank & comments only in the input
Browse files Browse the repository at this point in the history
NOTE that the exception output message had changed since v0.13.2.

ref:

- #21
  • Loading branch information
brodybits committed Jan 24, 2023
1 parent de64fdb commit fd305a4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/fixtures/comments-only.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// comments-only.js
Empty file added tests/fixtures/empty-source.js
Empty file.
47 changes: 47 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,50 @@ test("handle umd with esm", async () => {
},
});
});

test("cjs with empty source input (console warning expected in the Jest output)", async () => {
const snapshotPath = "fixtures/empty-source.size-snapshot.json";
await runRollup({
input: "./fixtures/empty-source.js",
plugins: [sizeSnapshot({ snapshotPath })],
output: { file: path.resolve("fixtures/output.js"), format: "cjs" },
});
const snapshot = pullSnapshot(snapshotPath);

expect(snapshot).toMatchObject({
"output.js": {
bundled: 15,
minified: 13,
gzipped: 33,
},
});
});

test("cjs with comments only (console warning expected in the Jest output)", async () => {
const snapshotPath = "fixtures/comments-only.size-snapshot.json";
await runRollup({
input: "./fixtures/comments-only.js",
plugins: [sizeSnapshot({ snapshotPath })],
output: { file: path.resolve("fixtures/output.js"), format: "cjs" },
});
const snapshot = pullSnapshot(snapshotPath);

expect(snapshot).toMatchObject({
"output.js": {
bundled: 15,
minified: 13,
gzipped: 33,
},
});
});

test("reproduce failure for esm with comments only ref: brodybits/rollup-plugin-size-snapshot#21", async () => {
const snapshotPath = "fixtures/comments-only.size-snapshot.json";
await expect(async () => {
await runRollup({
input: "./fixtures/comments-only.js",
plugins: [sizeSnapshot({ snapshotPath })],
output: { file: path.resolve("fixtures/output.js"), format: "esm" },
});
}).rejects.toThrow(/INTERNAL ERROR - terser error/); // was "No content" in v0.13.2
});

0 comments on commit fd305a4

Please sign in to comment.