@@ -3,6 +3,7 @@ import { afterEach, describe, it } from 'mocha';
33
44import {
55 collectEvents ,
6+ expectNoTracingActivity ,
67 getTracingChannel ,
78} from '../../__testUtils__/diagnosticsTestUtils.js' ;
89
@@ -173,13 +174,15 @@ describe('execute diagnostics channel', () => {
173174 }
174175 } ) ;
175176
176- it ( 'does nothing when no subscribers are attached' , ( ) => {
177+ it ( 'does not call tracing methods when no subscribers are attached' , async ( ) => {
177178 const document = parse ( '{ sync }' ) ;
178- const result = execute ( {
179- schema,
180- document,
181- rootValue : { sync : ( ) => 'hello' } ,
182- } ) ;
179+ const result = await expectNoTracingActivity ( executeChannel , ( ) =>
180+ execute ( {
181+ schema,
182+ document,
183+ rootValue : { sync : ( ) => 'hello' } ,
184+ } ) ,
185+ ) ;
183186 expect ( result ) . to . deep . equal ( { data : { sync : 'hello' } } ) ;
184187 } ) ;
185188} ) ;
@@ -257,18 +260,19 @@ describe('subscribe diagnostics channel', () => {
257260 expect ( active . events . map ( ( e ) => e . kind ) ) . to . deep . equal ( [ 'start' , 'end' ] ) ;
258261 } ) ;
259262
260- it ( 'does nothing when no subscribers are attached' , async ( ) => {
263+ it ( 'does not call tracing methods when no subscribers are attached' , async ( ) => {
261264 const document = parse ( 'subscription { tick }' ) ;
262265
263- const result = subscribe ( {
264- schema,
265- document,
266- rootValue : { tick : twoTicks } ,
267- } ) ;
268- const resolved = isPromise ( result ) ? await result : result ;
269- if ( isAsyncIterable ( resolved ) ) {
266+ await expectNoTracingActivity ( subscribeChannel , async ( ) => {
267+ const result = subscribe ( {
268+ schema,
269+ document,
270+ rootValue : { tick : twoTicks } ,
271+ } ) ;
272+ const resolved = isPromise ( result ) ? await result : result ;
273+ assert ( isAsyncIterable ( resolved ) ) ;
270274 await resolved . return ?.( ) ;
271- }
275+ } ) ;
272276 } ) ;
273277} ) ;
274278
@@ -449,14 +453,14 @@ describe('resolve diagnostics channel', () => {
449453 ] ) ;
450454 } ) ;
451455
452- it ( 'does nothing when no subscribers are attached' , ( ) => {
453- const result = execute ( {
454- schema ,
455- document : parse ( '{ sync }' ) ,
456- rootValue : { sync : ( ) => 'hello' } ,
457- } ) ;
458- if ( isPromise ( result ) ) {
459- throw new Error ( 'expected sync' ) ;
460- }
456+ it ( 'does not call tracing methods when no subscribers are attached' , async ( ) => {
457+ const result = await expectNoTracingActivity ( resolveChannel , ( ) =>
458+ execute ( {
459+ schema ,
460+ document : parse ( '{ sync }' ) ,
461+ rootValue : { sync : ( ) => 'hello' } ,
462+ } ) ,
463+ ) ;
464+ expect ( result ) . to . deep . equal ( { data : { sync : 'hello' } } ) ;
461465 } ) ;
462466} ) ;
0 commit comments