Assertions
Pest Bridge Plugin inherits all assertions from Pest's browser plugin. Here's a comprehensive reference.
Text Assertions
assertSee
Assert that text is visible on the page:
$this->bridge('/')
->assertSee('Welcome');assertDontSee
Assert that text is NOT visible on the page:
$this->bridge('/')
->assertDontSee('Error');assertSeeIn
Assert that text is visible within a specific element:
$this->bridge('/dashboard')
->assertSeeIn('[data-testid="header"]', 'Dashboard')
->assertSeeIn('.user-name', 'John Doe');assertDontSeeIn
Assert that text is NOT visible within a specific element:
$this->bridge('/dashboard')
->assertDontSeeIn('[data-testid="error-container"]', 'Error occurred');assertSeeAnythingIn
Assert that an element contains any text content:
$this->bridge('/dashboard')
->assertSeeAnythingIn('[data-testid="content"]');assertSeeNothingIn
Assert that an element is empty (contains no text):
$this->bridge('/form')
->assertSeeNothingIn('[data-testid="error-message"]');assertSeeLink
Assert that a link with specific text is visible:
$this->bridge('/')
->assertSeeLink('About Us')
->assertSeeLink('Contact');assertDontSeeLink
Assert that a link with specific text is NOT visible:
$this->bridge('/')
->assertDontSeeLink('Admin Panel');assertSourceHas
Assert that the page source contains specific HTML:
$this->bridge('/')
->assertSourceHas('<h1>Welcome</h1>')
->assertSourceHas('data-testid="main-content"');assertSourceMissing
Assert that the page source does NOT contain specific HTML:
$this->bridge('/')
->assertSourceMissing('<div class="error">');assertCount
Assert the number of elements matching a selector:
$this->bridge('/products')
->assertCount('[data-testid="product-card"]', 5)
->assertCount('.cart-item', 3);Element Assertions
assertVisible
Assert that an element is visible:
$this->bridge('/login')
->assertVisible('[data-testid="login-form"]')
->assertVisible('input[type="email"]')
->assertVisible('button[type="submit"]');assertNotVisible
Assert that an element is NOT visible:
$this->bridge('/')
->assertNotVisible('[data-testid="modal"]')
->assertNotVisible('.error-message');assertPresent
Assert that an element exists in the DOM (even if not visible):
$this->bridge('/')
->assertPresent('[data-testid="hidden-field"]');assertMissing
Assert that an element does NOT exist in the DOM:
$this->bridge('/')
->assertMissing('[data-testid="admin-panel"]');assertNotPresent
Assert that an element is NOT present in the DOM (alias for assertMissing):
$this->bridge('/')
->assertNotPresent('[data-testid="deleted-item"]');URL Assertions
assertPathContains
Assert that the current URL path contains a string:
$this->bridge('/login')
->fill('[data-testid="email"]', 'user@example.com')
->fill('[data-testid="password"]', 'password')
->click('[data-testid="login-button"]')
->wait(2)
->assertPathContains('/dashboard');assertPathIs
Assert that the current URL path exactly matches:
$this->bridge('/')
->assertPathIs('/');assertQueryStringHas
Assert that the URL has a query parameter:
$this->bridge('/search?q=test')
->assertQueryStringHas('q', 'test');
// Check parameter exists without value
$this->bridge('/search?q=test')
->assertQueryStringHas('q');assertQueryStringMissing
Assert that the URL does NOT have a query parameter:
$this->bridge('/products')
->assertQueryStringMissing('page');assertUrlIs
Assert the full URL matches exactly:
$this->bridge('/dashboard')
->assertUrlIs('http://localhost:5173/dashboard');assertSchemeIs
Assert the URL scheme:
$this->bridge('/')
->assertSchemeIs('https');assertSchemeIsNot
Assert the URL scheme is NOT a specific value:
$this->bridge('/')
->assertSchemeIsNot('http');assertHostIs
Assert the URL host:
$this->bridge('/')
->assertHostIs('localhost');assertHostIsNot
Assert the URL host is NOT a specific value:
$this->bridge('/')
->assertHostIsNot('example.com');assertPortIs
Assert the URL port:
$this->bridge('/')
->assertPortIs('5173');assertPortIsNot
Assert the URL port is NOT a specific value:
$this->bridge('/')
->assertPortIsNot('3000');assertPathIsNot
Assert the URL path is NOT a specific value:
$this->bridge('/dashboard')
->assertPathIsNot('/login');assertPathBeginsWith
Assert the URL path starts with a string:
$this->bridge('/users/123/profile')
->assertPathBeginsWith('/users');assertPathEndsWith
Assert the URL path ends with a string:
$this->bridge('/users/123/profile')
->assertPathEndsWith('/profile');assertFragmentIs
Assert the URL fragment (hash):
$this->bridge('/docs#installation')
->assertFragmentIs('installation');assertFragmentIsNot
Assert the URL fragment is NOT a specific value:
$this->bridge('/docs#installation')
->assertFragmentIsNot('getting-started');assertFragmentBeginsWith
Assert the URL fragment starts with a string:
$this->bridge('/docs#section-2')
->assertFragmentBeginsWith('section');Form Assertions
assertValue
Assert that an input has a specific value:
$this->bridge('/profile')
->assertValue('[data-testid="email-input"]', 'user@example.com');assertChecked
Assert that a checkbox is checked:
$this->bridge('/settings')
->assertChecked('[data-testid="newsletter-checkbox"]');assertNotChecked
Assert that a checkbox is NOT checked:
$this->bridge('/settings')
->assertNotChecked('[data-testid="marketing-checkbox"]');assertSelected
Assert that a select option is selected:
$this->bridge('/settings')
->assertSelected('[data-testid="language-select"]', 'en');assertNotSelected
Assert that a select option is NOT selected:
$this->bridge('/settings')
->assertNotSelected('[data-testid="country-select"]', 'UK');assertValueIsNot
Assert that an input does NOT have a specific value:
$this->bridge('/profile')
->assertValueIsNot('[data-testid="email-input"]', 'invalid@example.com');assertIndeterminate
Assert that a checkbox is in indeterminate state:
$this->bridge('/tree-view')
->assertIndeterminate('[data-testid="parent-checkbox"]');assertRadioSelected
Assert that a radio button option is selected:
$this->bridge('/survey')
->assertRadioSelected('size', 'large');assertRadioNotSelected
Assert that a radio button option is NOT selected:
$this->bridge('/survey')
->assertRadioNotSelected('size', 'small');assertEnabled
Assert that a form field is enabled:
$this->bridge('/form')
->assertEnabled('[data-testid="email-input"]');assertDisabled
Assert that a form field is disabled:
$this->bridge('/form')
->assertDisabled('[data-testid="submit-button"]');assertButtonEnabled
Assert that a button is enabled (by button text):
$this->bridge('/checkout')
->assertButtonEnabled('Complete Order');assertButtonDisabled
Assert that a button is disabled (by button text):
$this->bridge('/checkout')
->assertButtonDisabled('Complete Order');Page Assertions
assertTitle
Assert the page title:
$this->bridge('/')
->assertTitle('Home - My App');assertTitleContains
Assert the page title contains text:
$this->bridge('/dashboard')
->assertTitleContains('Dashboard');Attribute Assertions
assertAttribute
Assert that an element has a specific attribute value:
$this->bridge('/form')
->assertAttribute('[data-testid="email-input"]', 'type', 'email')
->assertAttribute('[data-testid="submit-button"]', 'disabled', 'true');assertAttributeMissing
Assert that an element does NOT have a specific attribute:
$this->bridge('/form')
->assertAttributeMissing('[data-testid="submit-button"]', 'disabled');assertAttributeContains
Assert that an attribute value contains a string:
$this->bridge('/dashboard')
->assertAttributeContains('[data-testid="container"]', 'class', 'active');assertAttributeDoesntContain
Assert that an attribute value does NOT contain a string:
$this->bridge('/dashboard')
->assertAttributeDoesntContain('[data-testid="container"]', 'class', 'hidden');assertAriaAttribute
Assert an ARIA attribute value:
$this->bridge('/modal')
->assertAriaAttribute('[data-testid="close-button"]', 'label', 'Close dialog');assertDataAttribute
Assert a data attribute value:
$this->bridge('/products')
->assertDataAttribute('[data-testid="product-card"]', 'id', '123')
->assertDataAttribute('[data-testid="product-card"]', 'category', 'electronics');Quality Assertions
assertNoSmoke
Assert no console logs or JavaScript errors on the page:
$this->bridge('/')
->assertNoSmoke();assertNoConsoleLogs
Assert no console logs on the page:
$this->bridge('/dashboard')
->assertNoConsoleLogs();assertNoJavaScriptErrors
Assert no JavaScript errors on the page:
$this->bridge('/app')
->assertNoJavaScriptErrors();assertNoAccessibilityIssues
Assert no accessibility issues (WCAG compliance). Levels: 0 (critical), 1 (serious), 2 (moderate), 3 (minor):
// Default level 1 (serious issues and above)
$this->bridge('/')
->assertNoAccessibilityIssues();
// Only critical issues (level 0)
$this->bridge('/')
->assertNoAccessibilityIssues(0);
// All issues including minor (level 3)
$this->bridge('/')
->assertNoAccessibilityIssues(3);assertScreenshotMatches
Assert that the current page matches a baseline screenshot (visual regression testing):
// Basic screenshot comparison
$this->bridge('/dashboard')
->assertScreenshotMatches();
// Full page screenshot with diff output
$this->bridge('/dashboard')
->assertScreenshotMatches(fullPage: true, diff: true);Chaining Assertions
All assertions are chainable:
$this->bridge('/dashboard')
->assertTitle('Dashboard - My App')
->assertSee('Welcome back')
->assertVisible('[data-testid="user-menu"]')
->assertSeeIn('[data-testid="sidebar"]', 'Settings')
->assertNotVisible('[data-testid="loading-spinner"]');Assertions with Actions
Combine assertions with actions:
test('complete user flow', function () {
$this->bridge('/login')
->assertVisible('[data-testid="login-form"]')
->fill('[data-testid="email"]', 'user@example.com')
->assertValue('[data-testid="email"]', 'user@example.com')
->fill('[data-testid="password"]', 'password')
->click('[data-testid="submit"]')
->wait(2)
->assertPathContains('/dashboard')
->assertSee('Welcome')
->assertNotVisible('[data-testid="login-form"]');
});Custom Assertion Messages
For clearer test failures, assertions support custom messages:
$this->bridge('/')
->assertSee('Welcome', 'Homepage should display welcome message');Screenshot on Failure
When an assertion fails, Pest automatically captures a screenshot. Find them in:
Tests/Browser/Screenshots/The filename corresponds to the test name, making it easy to debug failures.