Overview
It is critical to use test ads during development so that you can click on them without charging Google advertisers. If you click on too many ads without being in test mode, you risk your account being flagged for invalid activity.
Never use production ad unit IDs during development. Always use test ads to avoid account suspension.
Method 1: Google Demo Ad Units
The quickest way to enable testing is to use Google-provided test ad units. These ad units are not associated with your AdMob account, so there’s no risk of your account generating invalid traffic.
Test Ad Unit IDs
| Ad Format | Android Demo ID | iOS Demo ID |
|---|
| App Open | ca-app-pub-3940256099942544/9257395921 | ca-app-pub-3940256099942544/5662855259 |
| Banner | ca-app-pub-3940256099942544/6300978111 | ca-app-pub-3940256099942544/2934735716 |
| Interstitial | ca-app-pub-3940256099942544/1033173712 | ca-app-pub-3940256099942544/4411468910 |
| Interstitial Video | ca-app-pub-3940256099942544/8691691433 | ca-app-pub-3940256099942544/5135589807 |
| Rewarded | ca-app-pub-3940256099942544/5224354917 | ca-app-pub-3940256099942544/1712485313 |
| Rewarded Interstitial | ca-app-pub-3940256099942544/5354046379 | ca-app-pub-3940256099942544/6978759866 |
| Native Advanced | ca-app-pub-3940256099942544/2247696110 | ca-app-pub-3940256099942544/3986624511 |
| Native Advanced Video | ca-app-pub-3940256099942544/1044960115 | ca-app-pub-3940256099942544/2521693316 |
Run npx admob-plus test-ids in your terminal to display this table.
Using Demo Ad Units
Simply use these test ad unit IDs when creating ads:
// Banner ad with test ad unit
const banner = new admob.BannerAd({
adUnitId: 'ca-app-pub-3940256099942544/6300978111', // Test ID
});
await banner.show();
// Interstitial ad with test ad unit
const interstitial = new admob.InterstitialAd({
adUnitId: 'ca-app-pub-3940256099942544/1033173712', // Test ID
});
await interstitial.load();
await interstitial.show();
// Rewarded ad with test ad unit
const rewarded = new admob.RewardedAd({
adUnitId: 'ca-app-pub-3940256099942544/5224354917', // Test ID
});
await rewarded.load();
await rewarded.show();
Remember to replace test ad unit IDs with your production ad unit IDs before releasing your app.
Method 2: Test Device IDs
Another way to test is to register your device as a test device. This allows you to use your real ad unit IDs while still receiving test ads.
Step 1: Get Your Test Device ID
Load your ads-integrated app and make an ad request. Your test device ID will be printed to the console/logcat output.
Android (logcat):
I/Ads: Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("33BE2250B43518CCDA7DE426D04EE231"))
iOS (Xcode console):
<Google> To enable debug mode for this device, set:
GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = @[ @"33BE2250B43518CCDA7DE426D04EE231" ];
Add your test device ID using the configure() method:
document.addEventListener('deviceready', async () => {
await admob.start();
// Configure test devices
await admob.configure({
testDeviceIds: ['33BE2250B43518CCDA7DE426D04EE231'],
});
// Now use your real ad unit IDs
const banner = new admob.BannerAd({
adUnitId: 'ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY', // Your real ad unit
});
await banner.show();
}, false);
Multiple Test Devices
You can register multiple test devices:
await admob.configure({
testDeviceIds: [
'33BE2250B43518CCDA7DE426D04EE231', // Device 1
'B6D3A0A9F0D6D3C9E7F8A4B2C1D3E4F5', // Device 2
'C7E4B1BAF1E7E4DAF8G9B5C3D2E4F5G6', // Device 3
],
});
Step 3: Verify Test Ads
When configured correctly, test ads will display a “Test Ad” label:
- Google ads will show a “Test Ad” label centered at the top of the ad
- These ads are safe to click without risk to your account
- Test ad requests, impressions, and clicks will not appear in your account reports
Android emulators and iOS simulators are automatically configured as test devices. You don’t need to add their device IDs.
Complete Example
Here’s a complete example using both methods:
document.addEventListener('deviceready', async () => {
try {
// Start AdMob
const { version } = await admob.start();
console.log(`AdMob SDK v${version}`);
// Configure test devices
await admob.configure({
testDeviceIds: ['33BE2250B43518CCDA7DE426D04EE231'],
});
// Example 1: Using demo ad unit (recommended for testing)
const testBanner = new admob.BannerAd({
adUnitId: 'ca-app-pub-3940256099942544/6300978111',
});
await testBanner.show();
// Example 2: Using your real ad unit with test device ID
const productionBanner = new admob.BannerAd({
adUnitId: 'ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY',
});
await productionBanner.show();
// Both will show test ads with the "Test Ad" label
} catch (error) {
console.error('Error:', error);
}
}, false);
Environment-Based Configuration
For a production app, conditionally use test ads based on build configuration:
const isDevelopment = process.env.NODE_ENV === 'development';
const AD_UNITS = {
banner: isDevelopment
? 'ca-app-pub-3940256099942544/6300978111' // Test ID
: 'ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY', // Production ID
interstitial: isDevelopment
? 'ca-app-pub-3940256099942544/1033173712' // Test ID
: 'ca-app-pub-XXXXXXXXXXXXXXXX/ZZZZZZZZZZ', // Production ID
};
// Use in your app
const banner = new admob.BannerAd({
adUnitId: AD_UNITS.banner,
});
Debugging Tips
Verify Test Mode is Active
- Load an ad in your app
- Look for the “Test Ad” label on the ad
- If you don’t see the label, check:
- Device ID is correctly copied (no spaces or extra characters)
configure() was called before loading ads
- You’re testing on the correct device
Common Issues
Issue: Ads show “Test Ad” label in production buildSolution: Remove test device IDs and use production ad unit IDs before release.
Issue: No ads shown during testingSolution: Ensure you’re using valid test ad unit IDs from the table above. Check console for error messages.
Before Going to Production
Before releasing your app:
Remove Test Device IDs
Remove or comment out the testDeviceIds configuration:await admob.configure({
// testDeviceIds: ['33BE2250B43518CCDA7DE426D04EE231'], // Remove this
});
Replace Ad Unit IDs
Replace all test ad unit IDs with your production ad unit IDs from the AdMob console.
Test Production Build
Test your production build to ensure:
- Ads load correctly
- No “Test Ad” labels appear
- Ads are appropriate for your content rating
Best Practices
Use Google’s demo ad units during initial development
Use test device IDs when testing with your real ad units
Never click on production ads, even during testing
Remove all test configurations before releasing to production
Use environment variables to switch between test and production ad units