Skip to content

Commit 674ccbe

Browse files
committed
adjust tests
1 parent 9e80d2f commit 674ccbe

File tree

2 files changed

+32
-39
lines changed

2 files changed

+32
-39
lines changed

packages/bundler-plugin-core/test/option-mappings.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe("normalizeUserOptions()", () => {
3434
silent: false,
3535
telemetry: true,
3636
injectReleasesMap: false,
37+
url: "https://sentry.io",
3738
});
3839
});
3940

@@ -76,6 +77,7 @@ describe("normalizeUserOptions()", () => {
7677
silent: false,
7778
telemetry: true,
7879
injectReleasesMap: false,
80+
url: "https://sentry.io",
7981
});
8082
});
8183

@@ -104,6 +106,35 @@ describe("normalizeUserOptions()", () => {
104106
process.env["SENTRY_HEADER"] = _original_SENTRY_HEADER;
105107
process.env["CUSTOM_HEADER"] = _original_CUSTOM_HEADER;
106108
});
109+
110+
test.each(["https://sentry.io", undefined])(
111+
"should enable telemetry if `telemetry` is true and Sentry SaaS URL (%s) is used",
112+
(url) => {
113+
const options = {
114+
include: "",
115+
url,
116+
};
117+
118+
expect(normalizeUserOptions(options).telemetry).toBe(true);
119+
}
120+
);
121+
122+
test.each([
123+
[true, "https://selfhostedSentry.io"],
124+
[false, "https://sentry.io"],
125+
[false, "https://selfhostedSentry.io"],
126+
])(
127+
"should disable telemetry if `telemetry` is %s and Sentry SaaS URL (%s) is used",
128+
(telemetry, url) => {
129+
const options = {
130+
include: "",
131+
telemetry,
132+
url,
133+
};
134+
135+
expect(normalizeUserOptions(options).telemetry).toBe(false);
136+
}
137+
);
107138
});
108139

109140
describe("validateOptions", () => {

packages/bundler-plugin-core/test/sentry/telemetry.test.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,12 @@
1-
import { Hub, NodeClient } from "@sentry/node";
1+
import { Hub } from "@sentry/node";
22
import { InternalOptions } from "../../src/options-mapping";
33
import { SentryCLILike } from "../../src/sentry/cli";
44
import {
55
addPluginOptionTags,
66
captureMinimalError,
7-
makeSentryClient,
87
turnOffTelemetryForSelfHostedSentry,
98
} from "../../src/sentry/telemetry";
109

11-
describe("makeSentryClient", () => {
12-
const dsn = "https://abc@sentry.io:1234/subpath/123";
13-
14-
it("should create a client that sends stuff if `telemetry` is enabled and Sentry SaaS is used", () => {
15-
const { client } = makeSentryClient(dsn, true, "https://sentry.io");
16-
expect(client).toBeInstanceOf(NodeClient);
17-
expect(client.getOptions()).toMatchObject({
18-
dsn,
19-
enabled: true,
20-
tracesSampleRate: 1.0,
21-
sampleRate: 1.0,
22-
release: __PACKAGE_VERSION__,
23-
tracePropagationTargets: ["sentry.io/api"],
24-
});
25-
});
26-
27-
it.each([
28-
[true, "https://selfhostedSentry.io"],
29-
[false, "https://sentry.io"],
30-
[false, "https://selfhostedSentry.io"],
31-
])(
32-
"should create a client that doesnt sends stuff if `telemetry` is `%s` and URL is '%s'",
33-
(enabled, url) => {
34-
const { client } = makeSentryClient(dsn, enabled, url);
35-
expect(client).toBeInstanceOf(NodeClient);
36-
expect(client.getOptions()).toMatchObject({
37-
dsn,
38-
enabled: false,
39-
tracesSampleRate: 0,
40-
sampleRate: 0,
41-
release: __PACKAGE_VERSION__,
42-
tracePropagationTargets: ["sentry.io/api"],
43-
});
44-
}
45-
);
46-
});
47-
4810
describe("turnOffTelemetryForSelfHostedSentry", () => {
4911
const mockedCLI = {
5012
execute: jest

0 commit comments

Comments
 (0)