Building on @Vishal Aggarwal answer:
Testing if the element is attached to document or shadowDOM is probably a better solution than checking if the element is visible (the element can exists and not be visible, it happens quite often actually).
So, here you go:
await expect(page.locator('.somethingdoesnotexistYET')).toBeAttached()
With the docs