Prebid.js
Prebid.js copied to clipboard
Issue with gulp depending of my file name
Type of issue
Bug ?
Description
I am trying to rename my module bidwatchAnalyticsAdapter to oxxionAnalyticsAdapter. To do so, I've started by renaming files but when I do so I noticed the it makes gulp test
fail. The thing is that the error seems to be related to another module, it seems to be caused by the last test from test/spec/modules/cleanioRtdProvider_spec.js
gulp test-coverage
on my module's test file run without error, but gulp test
fail on :
FAILED TESTS:
BidWatch Analytics
main test flow
✖ test bidWon
Chrome Headless 97.0.4692.99 (Linux x86_64)
AssertError: expected track to be called once but was called twice
track({
args: {
auctionId: "1e8b993d-8f0a-4232-83eb-3639ddf3a44b",
bidId: "2bd3e8ff8a113f",
billingId: "21c70447-a01f-4779-b28b-fb6d09ae5e4c",
transactionId: "8b2a8629-d1ea-4bb1-aff0-e335b96dd002",
type: "impression",
vendor: "clean.io"
},
eventType: "billableEvent"
}) at /tmp/_karma_webpack_353917/commons.js:8292:15
track({
args: {
ad: "some html",
adId: "65d16ef039a97a",
adUnitCode: "tag_200123_banner",
adserverTargeting: {
hb_adid: "65d16ef039a97a",
hb_adomain: "example.com",
hb_bidder: "appnexus",
hb_format: "banner",
hb_pb: "20.000000",
hb_size: "970x250",
hb_source: "client"
},
auctionId: "1e8b993d-8f0a-4232-83eb-3639ddf3a44b",
bidder: "appnexus",
bidderCode: "appnexus",
cpm: 27.4276,
creativeId: "158533702",
currency: "USD",
height: 250,
mediaType: "banner",
meta: { advertiserDomains: ["example.com"] },
netRevenue: true,
originalBidder: "appnexus",
originalCpm: 25.02521,
originalCurrency: "EUR",
params: [{ placementId: 123456 }],
pbAg: "20.00",
pbCg: "20.000000",
pbDg: "20.00",
pbHg: "20.00",
pbLg: "5.00",
pbMg: "20.00",
requestId: "2bd3e8ff8a113f",
requestTimestamp: 1647424261189,
responseTimestamp: 1647424261558,
size: "970x250",
source: "client",
status: "rendered",
statusMessage: "Bid available",
timeToRespond: 369,
transactionId: "8b2a8629-d1ea-4bb1-aff0-e335b96dd002",
ttl: 2000,
width: 970
},
eventType: "bidWon"
}) at /tmp/_karma_webpack_353917/commons.js:8292:15
at Object.fail (node_modules/sinon/pkg/sinon.js:142:21)
at failAssertion (node_modules/sinon/pkg/sinon.js:101:16)
at Object.assertCallCount [as callCount] (node_modules/sinon/pkg/sinon.js:183:13)
at Context.<anonymous> (/tmp/_karma_webpack_353917/commons.js:236904:20)
The vendor: "clean.io"
does not come from my test file, I have no idea why it's added to my own tests
Steps to reproduce
git clone my test branch at https://github.com/mediasquare-developers/Prebid.js/tree/bidwatchRename
then run gulp test-coverage --file=test/spec/modules/oxxionAnalyticsAdapter_spec.js
and check it succeed
then run gulp test
and see the error mentioned above.
Did my module or another one failed in reseting or closing something that would explain the problem ? I checked but haven't found out what it could be.
Thanks for your help.
The cleanIO RTD provider replicates BID_WON
events into BILLABLE_EVENT
events (events):
https://github.com/prebid/Prebid.js/blob/5e18b2dce96549b9d340d1380d048561e780de61/modules/cleanioRtdProvider.js#L152-L169
This means that if the cleanIO module is loaded, a test (like yours) that fires a BID_WON event will see the generated BILLABLE_EVENT first. Renaming "bidwatch" to "oxxion" moved it past "cleanio" in the load order (alphabetically, b
< c
< o
), so you are seeing the side effect now - cleanio was not loaded for bidwatch.
The fastest fix is to modify your test expect an event with the expected properties (instead of the event).
CleanIO should probably enable that logic together with the module, instead of on load. That would make it easier to disable it once the cleanIO tests are done. FYI @alexeyst
I did guess it was related to alphabetical order yes. I am not sure what you mean by expecting an event instead of the event, so I think it might be fastet for me just to remove this test which does not really seem mandatory to me.
I am still a little bit worried that another module could interfer with my own tests but I guess it's a very specific case here.
Looking at that test again, I agree that the particular assertion that fails is not useful.
To avoid "interference" in your unit tests the best practice is to mock / stub all external state - in this case, mocking out events
would have isolated you from the problem.
@matthieularere-msq is this resolved?
Yes it's solves