File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export function setupIntegrationTest(): IntegrationTest {
6969 } ) ;
7070
7171 beforeEach ( async ( ) => {
72+ config . telemetry = "disabled" ;
7273 randomDbName = new ObjectId ( ) . toString ( ) ;
7374 } ) ;
7475
@@ -242,3 +243,28 @@ export function describeAtlas(name: number | string | Function | jest.FunctionLi
242243 describe ( name , fn ) ;
243244 } ) ;
244245}
246+
247+ // Telemetry control functions for tests
248+ export function disableTelemetry ( ) : void {
249+ process . env . DO_NOT_TRACK = "1" ;
250+ }
251+
252+ export function enableTelemetry ( ) : void {
253+ delete process . env . DO_NOT_TRACK ;
254+ }
255+
256+ export function withTelemetryDisabled ( fn : ( ) => Promise < void > | void ) : ( ) => Promise < void > {
257+ return async ( ) => {
258+ const originalValue = process . env . DO_NOT_TRACK ;
259+ disableTelemetry ( ) ;
260+ try {
261+ await fn ( ) ;
262+ } finally {
263+ if ( originalValue === undefined ) {
264+ delete process . env . DO_NOT_TRACK ;
265+ } else {
266+ process . env . DO_NOT_TRACK = originalValue ;
267+ }
268+ }
269+ } ;
270+ }
You can’t perform that action at this time.
0 commit comments