Skip to content

Commit 11d71fd

Browse files
authored
fix: update telemetry test mocks for @vscode/extension-telemetry v1.5.2
The dependabot PR bumped @vscode/extension-telemetry from ^0.8.4 to ^1.5.2. The old version (0.8.4) exported TelemetryReporter as a default export (exports.default), while the new version (1.5.2) exports it as a named export (exports.TelemetryReporter). The production code in telemetry/index.ts was correctly updated to use the named export (.TelemetryReporter), but the test mocks still used { default: Reporter } causing "TypeError: Reporter is not a constructor" in 5 unit tests. Updated all rewiremock calls from: rewiremock('@vscode/extension-telemetry').with({ default: Reporter }) to: rewiremock('@vscode/extension-telemetry').with({ TelemetryReporter: Reporter })
1 parent e5dc5aa commit 11d71fd

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/test/debugger/extension/adapter/factory.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ suite('Debugging - Adapter Factory', () => {
7373
readJSONSyncStub = sinon.stub(fs, 'readJSONSync');
7474
readJSONSyncStub.returns({ enableTelemetry: true });
7575
rewiremock.enable();
76-
rewiremock('@vscode/extension-telemetry').with({ default: Reporter });
76+
rewiremock('@vscode/extension-telemetry').with({ TelemetryReporter: Reporter });
7777
stateFactory = mock(PersistentStateFactory);
7878
state = mock(PersistentState) as PersistentState<boolean | undefined>;
7979
commandManager = mock(CommandManager);

src/test/telemetry/index.unit.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ suite('Telemetry', () => {
6161

6262
test('Send Telemetry', () => {
6363
rewiremock.enable();
64-
rewiremock('@vscode/extension-telemetry').with({ default: Reporter });
64+
rewiremock('@vscode/extension-telemetry').with({ TelemetryReporter: Reporter });
6565

6666
const eventName = 'Testing';
6767
const properties = { hello: 'world', foo: 'bar' };
@@ -75,7 +75,7 @@ suite('Telemetry', () => {
7575
});
7676
test('Send Telemetry with no properties', () => {
7777
rewiremock.enable();
78-
rewiremock('@vscode/extension-telemetry').with({ default: Reporter });
78+
rewiremock('@vscode/extension-telemetry').with({ TelemetryReporter: Reporter });
7979

8080
const eventName = 'Testing';
8181

@@ -87,7 +87,7 @@ suite('Telemetry', () => {
8787
});
8888
test('Send Telemetry with shared properties', () => {
8989
rewiremock.enable();
90-
rewiremock('@vscode/extension-telemetry').with({ default: Reporter });
90+
rewiremock('@vscode/extension-telemetry').with({ TelemetryReporter: Reporter });
9191

9292
const eventName = 'Testing';
9393
const properties = { hello: 'world', foo: 'bar' };
@@ -104,7 +104,7 @@ suite('Telemetry', () => {
104104
});
105105
test('Shared properties will replace existing ones', () => {
106106
rewiremock.enable();
107-
rewiremock('@vscode/extension-telemetry').with({ default: Reporter });
107+
rewiremock('@vscode/extension-telemetry').with({ TelemetryReporter: Reporter });
108108

109109
const eventName = 'Testing';
110110
const properties = { hello: 'world', foo: 'bar' };
@@ -122,7 +122,7 @@ suite('Telemetry', () => {
122122
test('Send Exception Telemetry', () => {
123123
rewiremock.enable();
124124
const error = new Error('Boo');
125-
rewiremock('@vscode/extension-telemetry').with({ default: Reporter });
125+
rewiremock('@vscode/extension-telemetry').with({ TelemetryReporter: Reporter });
126126

127127
const eventName = 'Testing';
128128
const measures = { start: 123, end: 987 };

0 commit comments

Comments
 (0)