Use a stable selector for each repeated item, then assert the expected list state with a retryable Cypress query. For example, cy.get('[data-cy="todo-item"]').should('have.length', 3) waits for three matching items to appear; add text and ordering checks when those are part of the requirement.
Choose a stable selector for list items
Give repeated elements a selector that describes their testing role, such as a dedicated data-cy attribute. This avoids tying the test to CSS classes that may change for styling reasons.
As an Amazon Associate I earn from qualifying purchases.
<ul>
<li data-cy="todo-item">Buy milk</li>
<li data-cy="todo-item">Walk the dog</li>
</ul>
Use the same selector in the test:
cy.get('[data-cy="todo-item"]')
Cypress’s cy.get() documentation covers selecting matching elements and using positional queries such as .first() and .eq().
Assert the expected number of items
Use .should('have.length', expectedCount) when the correct state has a known exact number of items:
#1 Best Overall
- Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.
cy.get('[data-cy="todo-item"]').should('have.length', 3)
Cypress retries linked queries and .should() assertions until they pass or time out. That makes this pattern useful for lists populated asynchronously: the assertion can pass when the third item is rendered instead of checking too early.
Prefer a positive assertion for the state you expect. A negative assertion can pass for unintended states—for example, a list that disappeared or contains an unexpected blank item—without proving that the correct items are present. If the requirement is a minimum or a range rather than an exact count, write an assertion that expresses that condition.
Check item text and ordering
Assert a few important positions
For a short list with position-specific requirements, use .first() or .eq(index) and assert the expected text:
Rank #2
- Storage: 16GB Flash Memory
- OS: Chrome OS
- Screen Size: 11.6"
cy.get('[data-cy="todo-item"]').first().should('contain', 'Buy milk')
cy.get('[data-cy="todo-item"]').eq(1).should('contain', 'Walk the dog')
Be precise about selector semantics. For example, ul li:first selects the first matching li across the page, while ul li:first-child can match the first child of each list.
Verify the entire ordered list
When membership, text, and order all matter, collect the rendered text and compare it with the expected array. Cypress demonstrates mapping selected elements to text and converting the result to a regular array before comparison in its introduction.
const expected = ['Walk the dog', 'Feed the cat', 'Write JavaScript']
cy.get('.connectors-list > li').should(($items) => {
const actual = $items.map((_, item) => item.innerText.trim()).get()
expect(actual).to.deep.equal(expected)
})
The callback form of .should() is retried. Keep it safe to run more than once: use assertions and pure inspection, not clicks, typing, or other side effects.
Rank #3
- Intel Processor Up to 2.80GHz, 4GB DDR4, 128GB Storage
- 15" FHD IPS Display, Intel UHD Graphics
- 1x USB Type C, 1 x USB Type A, 1x Headphone/Microphone Combo Jack, HDMI
- Fast WiFi and Bluetooth, Integrated Webcam
- Chrome OS, AC Charger Included, Pastel Silver
Wait for an asynchronously populated list
Keep the query and assertion in one retryable Cypress chain:
cy.get('[data-cy="todo-item"]').should('have.length', 3)
A linked query and its assertion are retried from the top of the query chain until the assertion succeeds or the command times out. By contrast, a .then() callback runs once with the elements found at that moment:
// Avoid this if the list is still being filled asynchronously
cy.get('[data-cy="todo-item"]').then(($items) => {
expect($items).to.have.length(3)
})
Use .then() when you need to act on a value after it is available, not as a substitute for a retryable assertion about a changing DOM. See Cypress’s retry-ability guide and .should() documentation for the behavior and callback rules.
Rank #4
- THE BETTER WAY TO LAPTOP – Imagine a Chromebook that’s as flexible as your day: thin and lightweight with built-in Google apps and stress-free security.
- TAKE HITS KEEP MOVING – Sleek, light, and built to last- the Chromebook 2-in-1 is just 0.69” thick and 3.3lbs. Enjoy long-lasting battery life, fast charging, and military-grade durability for nonstop productivity wherever life takes you.
- PERFORMANCE THAT MATCHES YOUR HUSTLE – Fuel your ideas with an Intel Core processor and 128GB storage. Boot up in under 10 seconds to start the day powerfully efficient.
- FLEX YOUR CREATIVITY ANYWHERE, ANYTIME – Create, work, or unwind your way with a versatile 2-in-1 design. Flip easily between laptop, tent, and tablet modes with a responsive touchscreen built for flexibility.
- BRILLIANT VIEWS AND IMMERSIVE AUDIO – See, hear, and create with awesome clarity. The WUXGA display brings rich detail to your work and play, while audio tuned by Waves MaxxAudio provides immersive, balanced sound.
Use fixtures for predictable expected rows
Fixtures are useful when a list should render a known set of records. They can hold test data separately from the spec and can be used to stub a network response, reducing reliance on changing backend data.
cy.fixture('users.json').then((users) => {
cy.get('[data-cy="user-row"]').should('have.length', users.length)
cy.get('[data-cy="user-email"]')
.first()
.should('have.text', users[0].email)
})
Cypress describes fixtures as a way to keep test data consistent between runs in its fixture documentation. In TypeScript, a type supplied to cy.fixture<User[]>() describes the yielded value; it does not validate that the fixture file actually matches that type.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Generate tests from records when needed
cy.fixture() runs within a test. It does not load data early enough to create new it() blocks. If you want one test per record, import the data when defining the tests. For large files or Node-side processing, Cypress recommends using cy.task() and returning only the data the test needs; see Writing and organizing tests.
Best Value
- FOR HOME, WORK, & SCHOOL – With an Intel processor, 14-inch display, custom-tuned stereo speakers, and long battery life, this Chromebook laptop lets you knock out any assignment or binge-watch your favorite shows..Voltage:5.0 volts
- HD DISPLAY, PORTABLE DESIGN – See every bit of detail on this micro-edge, anti-glare, 14-inch HD (1366 x 768) display (1); easily take this thin and lightweight laptop PC from room to room, on trips, or in a backpack.
- ALL-DAY PERFORMANCE – Reliably tackle all your assignments at once with the quad-core, Intel Celeron N4120—the perfect processor for performance, power consumption, and value (2).
- 4K READY – Smoothly stream 4K content and play your favorite next-gen games with Intel UHD Graphics 600 (3) (4).
- MEMORY AND STORAGE – Enjoy a boost to your system’s performance with 4 GB of RAM while saving more of your favorite memories with 64 GB of reliable flash-based eMMC storage (5).
Pick the assertion pattern that matches the requirement
| Need | Pattern | What it establishes |
|---|---|---|
| Confirm collection size | .should('have.length', n) |
Exact expected cardinality, with retries while the list renders. |
| Check a few meaningful positions | .first() or .eq(i) plus a text assertion |
Readable checks for specific items at specific positions. |
| Check the whole ordered list | Map item text and deep-compare with an expected array | Membership, text, and order in one comparison. |
| Assert predictable rows | Fixture data plus DOM assertions | Compares rendered rows with known test records. |
| Generate one test per record | Import data when defining tests | Creates test blocks before test execution; a fixture call inside a test cannot do this. |
| Process a large file or use Node-side logic | cy.task() |
Keeps file processing on the server side and lets the task return the needed result. |
Troubleshoot list assertions
- The count assertion times out: Check that the selector matches the rendered item elements, that the expected count is correct for this test state, and that the page actually reaches that state. Keep the assertion in a retryable
.should()chain rather than checking once in.then(). - The count passes but the list is wrong: Count alone does not verify which records appear. Add text assertions for important positions or compare the complete rendered sequence with the expected array.
- The test passes when the list is missing: Replace a negative assertion with a positive assertion describing the intended count or content.
- A positional assertion targets an unexpected item: Confirm whether the selector means the first matching item globally or the first child in each list. Scope the query to the intended list and use
.first()or.eq()deliberately. - A callback causes repeated actions: Cypress may rerun a
.should(callback)callback. Keep it limited to assertions and pure DOM inspection; perform actions outside it. - Fixture typing appears to accept invalid data: A TypeScript generic describes the expected yielded type but does not validate fixture contents at runtime.
Or skip the browser setup
If your goal is to capture a page screenshot while testing a list page, ScreenshotNeo provides a one-request screenshot API. It can capture a rendered page, but it does not replace Cypress assertions about item count, text, or order. See the ScreenshotNeo website and API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. The service also has an MCP server for AI agents, with tools including take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallQuick Recap
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.




