Found an answer.
Summary of my fix:
.tsx
files in my test files..ts
or .tsx
files that, directly or indirectly, import images (like PNGs) or CSS.Best practice:
.ts
files (with no image/CSS imports) in your Playwright test files..tsx
files or any file that could eventually import images or styles.This approach will reliably prevent "Invalid or unexpected token" errors related to asset imports in your tests.