diff --git a/playground/test-utils.ts b/playground/test-utils.ts index b99daa846b2689..137abff2c4bd53 100644 --- a/playground/test-utils.ts +++ b/playground/test-utils.ts @@ -71,7 +71,11 @@ const timeout = (n: number) => new Promise((r) => setTimeout(r, n)) async function toEl(el: string | ElementHandle): Promise { if (typeof el === 'string') { - return await page.$(el) + const realEl = await page.$(el) + if (realEl == null) { + throw new Error(`Cannot find element: "${el}"`) + } + return realEl } return el }