Back to All Questions
Question 37 of 100
Assertions
Advanced
What are Non-Retrying (Generic) Assertions in Playwright?
The Answer
Non-retrying assertions are plain synchronous checks (similar to Jest's `expect`) that do NOT auto-wait. They evaluate immediately and are used for non-UI values like API response data, variables, or computed values.
Deep Dive Explanation
The key distinction: Web-First assertions like `expect(locator).toBeVisible()` retry. Generic assertions like `expect(value).toBe(x)` do not retry. Never use generic assertions on locators β always use Web-First assertions for DOM checks.
example.spec.ts
test('non-retrying assertions', async ({ request }) => {
const response = await request.get('/api/users/1');
// Non-retrying - evaluates immediately
expect(response.status()).toBe(200);
expect(response.ok()).toBeTruthy();
const body = await response.json();
expect(body.name).toBe('John Doe');
expect(body.role).toContain('admin');
expect(body.items).toHaveLength(3);
expect(body.score).toBeGreaterThan(0);
expect(body.email).toMatch(/@example\.com$/);
});