vitest-dev / vitest-dev/vitest

`await expect.element(page).not.toHaveTextContent()`

Open
#8,997 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: browser p2-nice-to-have
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Clear and concise description of the problem

When testing components, it is currently not possible to check that the rendering is empty (some of our components have conditions, and might not render anything.

expect.element(page) doesn't work because page is not a locator.

But I can't use page.getBy.... because there is nothing to get...

Suggested solution
await expect.element(page).not.toHaveTextContent()
Alternative

No response

Additional context

No response

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name implementation files or tests. Start by locating the expect.element API and the existing toHaveTextContent matcher tests, then check how page objects differ from locators. Done means the proposed negated assertion can verify that a component renders no content, with coverage for the empty-rendering case.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.