diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 358fd7bcf3a..cf4ccee17d0 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -895,6 +895,11 @@ export const spec = { payload.site.page = conf.kadpageurl.trim() || payload.site.page.trim(); payload.site.domain = _getDomainFromURL(payload.site.page); + // test bids + if (window.location.href.indexOf('pubmaticTest=true') !== -1) { + payload.test = 1; + } + // adding schain object if (validBidRequests[0].schain) { payload.source = { diff --git a/modules/pubmaticBidAdapter.md b/modules/pubmaticBidAdapter.md index 1948acba40f..fc7766430a2 100644 --- a/modules/pubmaticBidAdapter.md +++ b/modules/pubmaticBidAdapter.md @@ -199,4 +199,7 @@ pbjs.setConfig({ }); ``` -Note: Combine the above the configuration with any other UserSync configuration. Multiple setConfig() calls overwrite each other and only last call for a given attribute will take effect. +Note: Combine the above the configuration with any other UserSync configuration. Multiple setConfig() calls overwrite each other and only last call for a given attribute will take effect. + +Note: PubMatic will return a test-bid if "pubmaticTest=true" is present in page URL + diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index f0c97cd72f3..85d135d9f79 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -719,9 +719,23 @@ describe('PubMatic adapter', function () { expect(request.method).to.equal('POST'); }); + it('test flag not sent when pubmaticTest=true is absent in page url', function() { + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.test).to.equal(undefined); + }); + + it('test flag set to 1 when pubmaticTest=true is present in page url', function() { + window.location.href += '#pubmaticTest=true'; + // now all the test cases below will have window.location.href with #pubmaticTest=true + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.test).to.equal(1); + }); + it('Request params check', function () { - let request = spec.buildRequests(bidRequests); - let data = JSON.parse(request.data); + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); expect(data.at).to.equal(1); // auction type expect(data.cur[0]).to.equal('USD'); // currency expect(data.site.domain).to.be.a('string'); // domain should be set