Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6211

How to test void functions using jest

$
0
0

I have a function that returns nothing. How can we write the jest test cases to verify this function?

onSilentTrackReadyToPlay(callback: (trackState: string) => void): void {
    this.trackReadySubscription = this.MediaPlayerEventEmitter.addListener(
      'silentTrackReadyToPlay',
      (trackState) => {
        if (callback) {
          callback(trackState)
        }
      },
    )
  }

Viewing all articles
Browse latest Browse all 6211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>