Cypress tests often become flaky when developers assume cy.wait('@alias') waits for every new request. It doesn’t. Aliases capture only the first match, so later waits may resolve instantly. The fix: re-intercept before each occurrence or use times: 1 to create one-shot intercepts that “consume” themselves. But the real solution is avoiding network waits altogether. Instead, rely on user-visible, accessible UI states (spinners, aria-busy, disabled buttons, status messages). This makes tests stable, realistic, and far more reliable than waiting on network events.Cypress tests often become flaky when developers assume cy.wait('@alias') waits for every new request. It doesn’t. Aliases capture only the first match, so later waits may resolve instantly. The fix: re-intercept before each occurrence or use times: 1 to create one-shot intercepts that “consume” themselves. But the real solution is avoiding network waits altogether. Instead, rely on user-visible, accessible UI states (spinners, aria-busy, disabled buttons, status messages). This makes tests stable, realistic, and far more reliable than waiting on network events.

Achieving Reliable E2E Tests in Cypress: Overcome cy.wait Pitfalls

Cypress gives frontend engineers a superpower: the ability to write E2E tests that watch our app behave just like a real user would. But with great power comes… well, a lot of subtle flakiness if you’re not careful.

The cy.wait Illusion: What's Really Happening

The scenario is simple: you have a component that loads data, and after a user action, it loads new data using the same API endpoint. To ensure the new data has arrived, you intercept the request and then use cy.wait('@requestAlias') multiple times.

// A common, flawed approach: cy.intercept('GET', '/api/items/*', { fixture: 'item-1' }).as('getItems'); cy.visit('/items'); // 1. Wait for the initial load cy.wait('@getItems'); // ... User performs an action that triggers the SAME request ... // 2. Wait for the second load cy.wait('@getItems'); // <-- THIS IS THE PROBLEM

The Flaw

Cypress's cy.intercept logic is designed to capture a single match for an alias. When you call cy.wait('@getItems') for the first time, it finds the initial request, waits for its resolution, and then the alias is fulfilled.

When you call cy.wait('@getItems') a second time, Cypress does not reset the listener. Instead, it checks if a request has already been resolved with that alias. Because the first request has resolved, the second cy.wait command resolves immediately, without waiting for the new network call to finish. Your test is now racing against the network, not waiting for it.

Fix #1: Re-intercept before each expected request

(Works, explicit, but verbose)

cy.intercept('GET', '/api/items').as('getItems_1') cy.get('[data-testid=refresh]').click() cy.wait('@getItems_1') cy.intercept('GET', '/api/items').as('getItems_2') cy.get('[data-testid=load-more]').click() cy.wait('@getItems_2')

Clear, deterministic, but repetitive.

Fix #2: Use times: 1 to force Cypress to “consume” intercepts

(Cleaner: Cypress forgets the intercept after one match)

This is the missing tool many engineers don’t realize exists.

cy.intercept({ method: 'GET', pathname: '/api/items', times: 1 }).as('getItems') // trigger request 1 cy.get('[data-testid=refresh]').click() cy.wait('@getItems') cy.intercept({ method: 'GET', pathname: '/api/items', times: 1 }).as('getItems') // trigger request 2 cy.get('[data-testid=load-more]').click() cy.wait('@getItems')

Why this works:

  • times: 1 means Cypress removes the intercept after a single matching request
  • Re-declaring the intercept creates a fresh listener
  • Each cy.wait('@getItems') now truly waits for the next occurrence

This technique gives you explicit, occurrence-specific intercepts without alias clutter. For tests that must assert network behavior (payloads, headers, error flows), it’s a clean and robust pattern.

Fix #3: Stop waiting for requests altogether

(The best fix. UI > network.)

Here’s the golden rule:

That means the most stable tests assert what the user sees:

  • A loading spinner appears → disappears
  • A button becomes disabled → enabled
  • A success message appears when an action is complete.
  • The newly loaded element is now visible in the DOM.

Example with user-visible cues:

cy.get('[data-testid=refresh]').click() cy.get('[data-testid=spinner]').should('exist') cy.get('[data-testid=spinner]').should('not.exist') cy.get('[data-testid=item-list]') .children() .should('have.length.at.least', 1)

No reliance on internal network timing. No alias lifecycle. Zero flake.

Accessibility makes this even more robust

Accessible UI patterns make great Cypress hooks:

aria-busy attribute

<ul data-testid="item-list" aria-busy="true">

Test:

cy.get('[data-testid=item-list]').should('have.attr', 'aria-busy', 'false')

role="status" with live regions

<div role="status" aria-live="polite" data-testid="status"> Loading… </div>

Test:

cy.get('[data-testid=status]').should('contain', 'Loaded 10 items')

Disabled states for actions

cy.get('[data-testid=submit]').should('be.disabled') cy.get('[data-testid=submit]').should('not.be.disabled')

These patterns aid screen reader users and produce stable, deterministic E2E tests.

When waiting for requests is appropriate

There ARE valid scenarios:

  • Asserting payloads or query params
  • Mocking backend responses
  • Validating request ordering
  • Verifying retry logic
  • Testing error handling flows

For those cases: Combine times: 1 with explicit, fresh intercepts defined right before triggers.

For other cases: the test should rely on the UI state.

A combined real-world example

(Network + UI, the best of both worlds)

// UI-driven loading signal cy.get('[data-testid=create]').click() cy.get('[data-testid=spinner]').should('exist') // Network contract check cy.intercept({ method: 'POST', pathname: '/api/items', times: 1 }).as('postItem') cy.get('[data-testid=create]').click() cy.wait('@postItem') .its('request.body') .should('deep.include', { title: 'New item' }) // Final user-visible assertion cy.get('[data-testid=status]').should('contain', 'Item created')

The network part is accurate. The UI part is resilient. The test is rock-solid.

Final checklist

For accessible, deterministic, non-flaky Cypress tests

  • Prefer user-visible UI state, not network events
  • Use aria-busy, role="status", aria-live, and disabled states
  • When waiting for requests:
  • Re-intercept before each occurrence, OR
  • Use times: 1 to auto-expire the intercept
  • Avoid global, long-lived intercepts
  • Never assume cy.wait('@alias') waits “for the next request”
  • Make loading and completion states accessible (good for tests, good for users)

\

Piyasa Fırsatı
Threshold Logosu
Threshold Fiyatı(T)
$0.00939
$0.00939$0.00939
-0.63%
USD
Threshold (T) Canlı Fiyat Grafiği
Sorumluluk Reddi: Bu sitede yeniden yayınlanan makaleler, halka açık platformlardan alınmıştır ve yalnızca bilgilendirme amaçlıdır. MEXC'nin görüşlerini yansıtmayabilir. Tüm hakları telif sahiplerine aittir. Herhangi bir içeriğin üçüncü taraf haklarını ihlal ettiğini düşünüyorsanız, kaldırılması için lütfen service@support.mexc.com ile iletişime geçin. MEXC, içeriğin doğruluğu, eksiksizliği veya güncelliği konusunda hiçbir garanti vermez ve sağlanan bilgilere dayalı olarak alınan herhangi bir eylemden sorumlu değildir. İçerik, finansal, yasal veya diğer profesyonel tavsiye niteliğinde değildir ve MEXC tarafından bir tavsiye veya onay olarak değerlendirilmemelidir.

Ayrıca Şunları da Beğenebilirsiniz

Solana Treasury Stocks: Why Are These Companies Buying Up SOL?

Solana Treasury Stocks: Why Are These Companies Buying Up SOL?

The post Solana Treasury Stocks: Why Are These Companies Buying Up SOL? appeared on BitcoinEthereumNews.com. In 2020, everyone watched Strategy (called Microstrategy back then) scoop up Bitcoin and turn corporate crypto treasuries into a mainstream story. Now, a new wave is forming. And it’s centered on Solana. Dozens of companies are holding SOL as a bet on price. Except they’re not just holding. They’re building what’s being called Solana treasuries or Digital Asset Treasuries (DATs). These aren’t passive vaults. They’re active strategies that stake, earn yield, and tie into the fast-growing Solana ecosystem. Forward Industries, a Nasdaq-listed firm, recently bought more than 6.8 million SOL, making it the world’s largest Solana treasury company. Others like Helius Medical, Upexi, and DeFi Development are following a similar playbook, turning SOL into a centerpiece of their balance sheets. The trend is clear: Solana treasury stocks are emerging as a new class of crypto-exposed equities. And for investors, the question isn’t just who’s buying but why this strategy is spreading so fast. Key highlights: Solana treasuries (DATs) are corporate reserves of SOL designed to earn yield through staking and DeFi. Companies like Forward Industries, Helius Medical, Upexi, and DeFi Development Corp now hold millions of SOL. Public firms collectively own 17.1M SOL (≈$4B), which makes Solana one of the most adopted treasuries. Unlike Bitcoin treasuries, Solana holdings generate 6–8% annual rewards. It makes reserves into productive assets Solana treasury stocks are emerging as a new way for investors to gain indirect exposure to SOL. Risks remain: volatility, regulation, and concentrated holdings. But corporate adoption is growing fast. What is a Solana treasury (DAT)? A Solana treasury, sometimes called a Digital Asset Treasury (DAT), is when a company holds SOL as part of its balance sheet. But unlike Bitcoin treasuries, these usually aren’t just static reserves sitting in cold storage.  The key difference is productivity. SOL can be staked directly…
Paylaş
BitcoinEthereumNews2025/09/21 06:09
Unstoppable: Why No Public Company Can Ever Catch MicroStrategy’s Massive Bitcoin Holdings

Unstoppable: Why No Public Company Can Ever Catch MicroStrategy’s Massive Bitcoin Holdings

BitcoinWorld Unstoppable: Why No Public Company Can Ever Catch MicroStrategy’s Massive Bitcoin Holdings Imagine trying to build a mountain of gold, only to discover
Paylaş
bitcoinworld2025/12/17 14:30
Little Pepe soars from presale to market spotlight

Little Pepe soars from presale to market spotlight

The post Little Pepe soars from presale to market spotlight appeared on BitcoinEthereumNews.com. Disclosure: This article does not represent investment advice. The content and materials featured on this page are for educational purposes only. Early investors often capture the biggest rewards in crypto, and Little Pepe, priced under $0.005, is emerging as a memecoin that could rival big players. Summary LILPEPE has sold over 15 billion tokens in its presale, raising $25.4 million. The project’s community has grown to more than 41,000 holders and 30,000 Telegram members. Analysts suggest the token could see gains of up to 55x in two years and 100x by 2030. Crypto enthusiasts are aware that early investors tend to benefit the most from the market. Ripple (XRP) and Solana (SOL) are popular tokens that have profited traders. Little Pepe (LILPEPE), valued at less than $0.005, might produce more profit. LILPEPE is swiftly gaining popularity despite its recent introduction. Little Pepe: The market-changing memecoin Little Pepe has surprised everyone with its quick surge in cryptocurrencies. LILPEPE is becoming a popular meme currency. Its presale price is below $0.003. Strong foundations, a distinct market presence, and a developing and enthusiastic community distinguish it from other meme tokens. Many meme currencies use hype to attract investors, but LILPEPE’s rarity, community support, and distinctive roadmap have effectively drawn them in. Currently in its 13th presale stage, more than 15 billion tokens have been sold, generating over $25.4 million and sparking considerable interest. As the token approaches official listing, enthusiasm is growing, and many people believe it could be one of the following major memecoin success stories. LILPEPE’s growing community drives growth The strong community surrounding LILPEPE is a primary reason for its success. LILPEPE has built a loyal following of over 41,000 holders and about 30,000 active members on Telegram. Its rise is being fueled by this. The support of its community…
Paylaş
BitcoinEthereumNews2025/09/19 15:12