From 44edaea752b53e51dc04653d5e9aa9e044d8c6a1 Mon Sep 17 00:00:00 2001 From: Charlotte Date: Tue, 4 Feb 2025 15:52:39 +0000 Subject: [PATCH] silence typescript eslint warnings by forcing types instead of disabling eslint --- playwright/tests/targeting.spec.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/playwright/tests/targeting.spec.ts b/playwright/tests/targeting.spec.ts index 82cc4cc09..e0903c3de 100644 --- a/playwright/tests/targeting.spec.ts +++ b/playwright/tests/targeting.spec.ts @@ -72,16 +72,23 @@ test.describe('GAM targeting', () => { }); }); +type CriteoRequestPostBody = { + imp: Array<{ + id: string; + }>; +}; test.describe('Prebid targeting', () => { test.beforeEach(async ({ page }) => { return page.route(`${bidderURLs.criteo}**`, (route) => { const url = route.request().url(); if (url.includes(bidderURLs.criteo)) { // The mock bid reponse impid must match that sent in the request - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- see above - const impId = - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- we need the id from the request object - JSON.parse(String(route.request().postData())).imp[0].id; + const postData = route.request().postData(); + const json = JSON.parse( + postData?.toString() ?? '', + ) as CriteoRequestPostBody; + const impId = json.imp[0]?.id as string; + void route.fulfill({ body: JSON.stringify(criteoMockBidResponse(impId)), });