Testing modes

Test adBreak() integration

In order to test JavaScript code that uses the adBreak() API we provide a testing mode that can be enabled by adding data-adbreak-test="on"attribute on the adsbygoogle.js:

<script async
      data-adbreak-test="on"
      src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456789"
      crossorigin="anonymous">
</script>
<script>
   window.adsbygoogle = window.adsbygoogle || [];
   var adBreak = adConfig = function(o) {adsbygoogle.push(o);}
</script>

Testing mode:

  • Displays mock ads instead of requesting real ads.
  • Mimics real ads behaviour such as respecting your configured ad frequency.
  • Use console.log or break points to debug adBreakDone() and placementInfo.

Note: testing mode only allows you to test client-side JavaScript without sending ad requests to Google servers. It can't help you to detect issues related to misconfiguration of the AdSense code such as invalid `data-ad-client` values.

Test mode cycles between two scenarios: ad is loaded and ad is not loaded to emulate a real environment where ad will not always be available.