Testing ads

Test ad loading, consent, devices, and v17 outcomes without risking invalid traffic.

Use this page after the integration checks in Show your first ad. It is a long-lived reference for choosing safe test inventory, preparing devices, testing consent, and diagnosing request outcomes. It intentionally does not repeat the installation flow.

What to test

  • Unit tests: mock the native boundary and verify your UI, lifecycle, retry, and reward logic.
  • Integration tests: use Google's demo units or a registered test device to verify real SDK loading and rendering without generating invalid traffic.
  • Consent tests: force supported debug geographies, reset UMP state, and verify both eligible and ineligible request paths.

Quick path

Use the package's platform-aware TestIds for the first request. Emulators and simulators are automatically test devices. For a physical device, register its hashed id (see Register a test device) before calling initialize().

ts
import mobileAds, { TestIds } from 'react-native-google-mobile-ads';

await mobileAds().setRequestConfiguration({
  // Physical devices only; emulators and simulators are already test devices.
  testDeviceIdentifiers: ['YOUR-HASHED-TEST-DEVICE-ID'],
});

// Gather consent and confirm AdsConsent.canRequestAds before this point.
await mobileAds().initialize();

// Use the matching ID when creating the ad:
const bannerUnitId = TestIds.BANNER;

Request configuration applies to future requests, so set it before initialization and before any ad can preload. Resolve consent first as described in Consent & privacy basics.

Official test units

TestIds selects the official Android or iOS demo unit where the platforms use different IDs. These exports match the package source and include:

FormatExport
App openTestIds.APP_OPEN
Adaptive bannerTestIds.ADAPTIVE_BANNER
BannerTestIds.BANNER
InterstitialTestIds.INTERSTITIAL
Interstitial videoTestIds.INTERSTITIAL_VIDEO
RewardedTestIds.REWARDED
Rewarded interstitialTestIds.REWARDED_INTERSTITIAL
NativeTestIds.NATIVE
Native videoTestIds.NATIVE_VIDEO
Google Ad Manager app openTestIds.GAM_APP_OPEN
Google Ad Manager bannerTestIds.GAM_BANNER
Google Ad Manager interstitialTestIds.GAM_INTERSTITIAL
Google Ad Manager rewardedTestIds.GAM_REWARDED
Google Ad Manager rewarded interstitialTestIds.GAM_REWARDED_INTERSTITIAL
Google Ad Manager nativeTestIds.GAM_NATIVE
Google Ad Manager native videoTestIds.GAM_NATIVE_VIDEO

Google documents dedicated units for formats including Native, Rewarded Interstitial, and Google Ad Manager test ads. Prefer demo units during development. When using your own unit, confirm the request is in test mode before interacting with the ad. Demo units test Google demand; testing mediation requires your own configured unit plus test mode for every mediated network.

Register a test device

Emulators and simulators are automatically test devices on every backend: classic Android, Android Next-Gen, and iOS. You do not need to register them.

For a physical device, choose either method:

  1. Add the device in the AdMob UI using Google's test-device instructions.
  2. Run a development build on the device and make one ad request. The Google Mobile Ads SDK logs the device's hashed test-device id with a ready-to-paste configuration snippet: Android logcat shows a RequestConfiguration.Builder.setTestDeviceIds(...) call, and the Xcode console prints a line setting testDeviceIdentifiers that contains your device id. Copy that id into testDeviceIdentifiers as shown above.

Then restart the app and confirm that Google-served ads carry a Test Ad or Test mode label before interacting with them.

TestDeviceIds.EMULATOR is a classic-Android-only convenience that maps to the SDK's emulator alias. You never need it, because emulators are already test devices, and it has no effect on Android Next-Gen or iOS:

ts
import mobileAds, { TestDeviceIds } from 'react-native-google-mobile-ads';

await mobileAds().setRequestConfiguration({
  testDeviceIdentifiers: [TestDeviceIds.EMULATOR, 'YOUR-HASHED-TEST-DEVICE-ID'],
});

A Google test label does not prove that a mediated network is in test mode; follow each network's test instructions too.

Android emulator checklist

  • Prefer API 26 or newer for reliable modern AVD, logcat, and inspector tooling. This is a testing recommendation; the package's supported Android floor is defined in Prerequisites.
  • Update the AVD Google Play services. Google's tooling guidance recommends an emulator image with Google Play when Play services need to be updated.
  • Ensure network access is unrestricted and Private DNS, VPN, or content filtering is not blocking ad hosts.
  • The current Google Mobile Ads SDK declares the Android AD_ID permission and uses the Advertising ID when available. Advertising ID availability is separate from the hashed test device identifier; do not paste one in place of the other.
  • Continue using an official TestIds.* unit during development. If you use your own unit, confirm the response is marked as test mode before interacting with it. Any request not confirmed as test mode can return live inventory, so clicks or impressions can create invalid-traffic policy risk.

iOS simulator or real device

The iOS simulator is useful for basic loading and layout checks and does not need to be registered for UMP debug mode. Use a registered real device for the final smoke test, App Tracking Transparency, real UMP presentation and persistence, gesture launching, and device-specific network behavior. ATT state requires deleting and reinstalling the app to test the first prompt again.

Test consent

Debug geography works only for UMP test devices; iOS simulators are treated as test devices. Register a real device with the UMP identifier printed after requestInfoUpdate.

ts
import { AdsConsent, AdsConsentDebugGeography } from 'react-native-google-mobile-ads';

AdsConsent.reset();

const consentInfo = await AdsConsent.requestInfoUpdate({
  debugGeography: AdsConsentDebugGeography.EEA,
  testDeviceIdentifiers: ['YOUR-UMP-HASHED-TEST-DEVICE-ID'],
});

if (consentInfo.isConsentFormAvailable) {
  await AdsConsent.loadAndShowConsentFormIfRequired();
}

Call AdsConsent.reset() only in test tooling; then request fresh information. Remove debug identifiers and forced geography before release. Google's UMP guides describe the same test-device, forced-geography, and reset flow for Android and iOS.

Understand v17 outcomes

Do not branch only on legacy native integer error codes:

  • Fullscreen hooks expose lifecycle status, including loaded, no-fill, and error.
  • A load-time error.reason === 'no-fill' or 'mediation-no-fill' is an inventory outcome, not an integration exception. Retry later with backoff; do not create a request loop.
  • error.phase distinguishes a request failure (load) from a presentation failure (show). Show failures are errors even if their native message mentions inventory.
  • responseInfo records the response ID, winning adapter, waterfall rows, latency, and selected Google Ad Manager metadata. It can also be attached to error.
tsx
import { useEffect } from 'react';
import { Text } from 'react-native';
import { TestIds, useInterstitialAd } from 'react-native-google-mobile-ads';

export function InterstitialDiagnostics() {
  const { status, error, responseInfo } = useInterstitialAd({
    adUnitId: TestIds.INTERSTITIAL,
  });

  useEffect(() => {
    if (status === 'no-fill') {
      console.log('No inventory', error?.reason, responseInfo?.responseId);
    } else if (status === 'error') {
      console.error('Ad failure', error?.phase, error?.reason, error?.responseInfo);
    }
  }, [status, error, responseInfo]);

  return <Text>Ad status: {status}</Text>;
}

See React hooks for a complete component and Revenue telemetry and auction diagnostics for ResponseInfo.

When ads still do not show

ObservationNext step
status === 'no-fill'Treat it as inventory; inspect responseInfo, wait, and retry with backoff.
status === 'error'Branch on error.phase and error.reason; fix configuration or presentation before retrying.
Native fails only on an Android emulatorConfirm a Google Play system image and current Play services.
Consent says canRequestAds === falseComplete or refresh the UMP flow before initialization or loading.
A test unit works but your unit does notConfirm test mode, verify app/ad-unit status and format, then inspect the request.
Nothing reaches the networkDisable Private DNS/VPN filtering temporarily and verify device connectivity.

Continue with Common reasons ads do not show, then open Ad Inspector and the debug menu for request-level diagnosis.

Testing with Jest

The package currently does not export a consumer Jest setup file. Mock the surface your component uses in your own setup file, and keep integration tests on a development build:

ts
// jest.setup.ts
jest.mock('react-native-google-mobile-ads', () => ({
  __esModule: true,
  default: () => ({
    initialize: jest.fn().mockResolvedValue([]),
    setRequestConfiguration: jest.fn().mockResolvedValue(undefined),
  }),
  TestIds: {
    BANNER: 'test-banner',
    INTERSTITIAL: 'test-interstitial',
  },
  useInterstitialAd: jest.fn(() => ({
    status: 'loaded',
    error: null,
    responseInfo: null,
    show: jest.fn(),
    load: jest.fn(),
    retry: jest.fn(),
    destroy: jest.fn(),
  })),
}));
js
// jest.config.js
module.exports = {
  setupFiles: ['./jest.setup.ts'],
};