Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
suejung-sentry committed Sep 5, 2024
1 parent 623f779 commit 5b120b4
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions packages/bundle-analyzer/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,11 @@ describe("createAndUploadReport", () => {
it("should call all expected handlers for real runs", async () => {
coreOptions.dryRun = false;

let reportAsJson = "";
try {
reportAsJson = await createAndUploadReport(
"/path/to/build/directory",
coreOptions,
bundleAnalyzerOptions,
);
} catch (err) {
expect(err).toBeUndefined();
}
await createAndUploadReport(
"/path/to/build/directory",
coreOptions,
bundleAnalyzerOptions,
);

expect(normalizeOptions).toHaveBeenCalledWith(coreOptions);
expect(normalizeBundleAnalyzerOptions).toHaveBeenCalledWith(
Expand All @@ -149,13 +144,12 @@ describe("createAndUploadReport", () => {
EXPECTED_PACKAGE_NAME,
EXPECTED_PACKAGE_VERSION,
);
expect(reportAsJson).toBeTruthy();
});

it("should call all expected handlers for dry runs", async () => {
coreOptions.dryRun = true;

const reportAsJson = await createAndUploadReport(
await createAndUploadReport(
"/path/to/build/directory",
coreOptions,
bundleAnalyzerOptions,
Expand All @@ -174,7 +168,6 @@ describe("createAndUploadReport", () => {
EXPECTED_PACKAGE_VERSION,
);
expect(writeHandler).not.toHaveBeenCalled();
expect(reportAsJson).toBeTruthy();
});

it("should handle custom beforeReportUpload", async () => {
Expand All @@ -188,7 +181,7 @@ describe("createAndUploadReport", () => {
});
bundleAnalyzerOptions.beforeReportUpload = beforeReportUpload;

const reportAsJson = await createAndUploadReport(
await createAndUploadReport(
"/path/to/build/directory",
coreOptions,
bundleAnalyzerOptions,
Expand All @@ -197,7 +190,6 @@ describe("createAndUploadReport", () => {
expect(beforeReportUpload).toHaveBeenCalled();
expect(testFunc).toHaveBeenCalled();
expect(writeHandler).toHaveBeenCalled();
expect(reportAsJson).toBeTruthy();
});

it("should throw an error if options normalization fails", async () => {
Expand Down

0 comments on commit 5b120b4

Please sign in to comment.