Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add useful context to a Cypress assertion failure, pass a short label as the second argument to Chai’s expect inside a .should() callback. Cypress documents that these messages appear in the Command Log beside the assertion. For example, label what should be true after an action—not just the assertion syntax.

Add context to an assertion

Use expect(subject, 'message'), where the message names the expected behavior, element, or state. This is an assertion label for developers reading a test failure, not an error message shown to your application’s users.

cy.get('[data-testid="todos"]').should(($todos) => {
  expect($todos, 'todo list after adding one item').to.have.length(3)
  expect($todos, 'new todo is visible in the list').to.contain('Write tests')
})

Cypress’s .should() API documentation says string messages passed to an expect assertion are shown in the Command Log to give the assertion more context. The exact display can vary with Cypress, Chai, and reporter versions.

Write labels that help locate the failed expectation

A concise label should answer one practical question: which behavior was expected, which item is being checked, or what condition should hold after an action?

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
cy.get('[data-testid="submit"]').click()

cy.get('[data-testid="confirmation"]').should(($confirmation) => {
  expect($confirmation, 'confirmation after submitting the form')
    .to.contain('Your request was received')
})

Labels such as confirmation after submitting the form add intent. Labels such as should contain or value mostly repeat implementation details and may not help distinguish the failed check. Skip a label when the test title and assertion already make the expectation unmistakable.

Preserve Cypress retries

Cypress retries .should() assertions until they pass or time out. A callback passed to .should() can therefore run more than once; treat its contents as repeatable assertion code. A custom label annotates the expectation—it does not change the retry model.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
  • Keep the callback focused on assertions against its yielded subject.
  • Do not enqueue Cypress commands inside the callback.
  • Do not perform external or otherwise non-repeatable side effects there.

For multiple checks on one yielded subject, put separately labeled expect statements in the callback. If conditions are independent or a callback would obscure the test, make them separate queries and assertions instead.

Assert the required outcome, not merely a difference

A descriptive label cannot make an ambiguous assertion reliable. Cypress’s assertions guidance explains that negative assertions can pass for unintended reasons. After adding a todo, for example, asserting only that the list does not have two items could pass if the app deleted the list, removed an existing item, or inserted a blank item.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Prefer positive checks that establish the intended result, such as the expected number of items and the text of the newly added todo. Use a negative assertion when absence is itself the behavior under test and other states that would also satisfy it are controlled.

Choose selectors to match what the test promises

Selector choice affects what a failure means. Cypress’s best-practices guidance distinguishes text-based selection from stable data attributes:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  • Use a text query when the visible wording is part of the behavior. If changing “Submit” to “Save” should fail the test, checking the text expresses that contract.
  • Use a data attribute when the wording is incidental and a copy edit should not break the behavior test.

In either case, make the assertion prove the behavior that matters. A label should clarify that check, not compensate for a selector or assertion that tests the wrong thing.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Read the full Cypress failure report

A custom label is one clue, not a replacement for the rest of the report. Depending on the failure and the Cypress, browser, and reporter versions, output can include an error name and message, expected and actual values, a Learn more link, the source file and line or column, a code frame, and a stack trace. Cypress’s code-frame article describes how source context can make failures more readable and actionable.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
  1. Identify the failing expectation and read its label.
  2. Compare the expected and actual values or state shown in the report.
  3. Use the file location and code frame to inspect the assertion and nearby setup.
  4. Follow a documentation link or stack trace when the failure needs more context.

Cypress’s 2017 article “Good error messages” describes the design goal of showing the expected outcome and relevant UI information at failure time. Treat that as historical context, not a guarantee that every current failure type presents identical details.

Choose the simplest assertion form that explains the check

Choice Use it when What it clarifies
expect(subject, 'label') A particular expectation needs more context. Adds a short assertion-level label to the Command Log.
A built-in .should() chainer, such as .should('have.text', value) The chainer already says what is expected. Keeps a familiar, concise expected-versus-actual check.
A positive assertion The test must prove a specific state or result. Ties the failure to the required outcome.
A negative assertion Absence is the behavior under test and other explanations are controlled. Checks that a condition is absent, but may be ambiguous if many wrong states also satisfy it.
Text query or data attribute Choose based on whether visible wording is part of the behavior. Determines whether a copy change should fail the test.

Or skip the browser setup:

If your separate task is capturing a website screenshot, ScreenshotNeo provides a screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF. For example, this cURL request saves a WebP screenshot of Stripe:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for setup and options. Before capture, it can accept cookie or consent banners as a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up free for ScreenshotNeo.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.