question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not pass the test from the example "XHR spying and stubbing"

See original GitHub issue
  • version:
    • cyCypress package version: 2.1.0
    • Cypress binary version: 2.1.0
  • platform: OS X El Capitan
  • expected pass test in GUI
  • actual behavior: Error: CypressError: Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: ‘users’. No request ever occurred.

In CLI test passed. In GUI failed: 2018-04-04 15 43 50

AjaxList.vue:

<template>
  <div>
    <ul v-if="users && users.length">
      <li v-for="user of users" v-bind:key="user.id">
        <p><strong>{{user.id}}</strong> - {{user.name}}</p>
      </li>
    </ul>
  </div>
</template>

<script>
// example from https://alligator.io/vuejs/rest-api-axios/
import axios from 'axios';

export default {
  data() {
    return {
      users: []
    }
  },

  // Fetches posts when the component is created.
  created() {
    axios.get('http://jsonplaceholder.typicode.com/users?_limit=3')
    .then(response => {
      // JSON responses are automatically parsed.
      this.users = response.data
    })
  }
}
</script>

ajax-list-spec.js:

import AjaxList from '../../components/AjaxList.vue'
const mountVue = require('cypress-vue-unit-test')

/* eslint-env mocha */
describe('AjaxList', () => {
  beforeEach(mountVue(AjaxList))
  
  it('can inspect real data in XHR', () => {
    cy.server()
    cy.route('/users?_limit=3').as('users')
    cy.wait('@users').its('response.body').should('have.length', 3)
  })
})

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
alukoscommented, Apr 5, 2018

Thanks after a commit dfffa0a, the test passes 🙏. Cypress is a brilliant project 💎. Idea, implementation, support at the highest level. I wish you great success!

0reactions
jennifer-shehanecommented, Apr 30, 2021

Since this issue hasn’t had activity in a while, we’ll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we’d be happy to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does not pass the test from the example "XHR spying ... - GitHub
no, I'm not sure. when I create a new project and install cypress, the example_spec test.js passes, although there, too, there is route...
Read more >
Best Practices for Spies, Stubs and Mocks in Sinon.js
Learn about differences between spies, stubs and mocks, when and how to use them, and get a set of best practices to help...
Read more >
Cypress cy.intercept Problems - Gleb Bahmutov
To learn how to effectively spy and stub network requests in your Cypress tests, enroll in my online course Cypress Network Testing Exercises....
Read more >
Network Requests - Cypress Documentation
By not stubbing your responses, you are writing true end-to-end tests. This means you are driving your application the same way a real...
Read more >
Spies, Stubs, and Mocks: An Introduction to Testing Strategies
We use stubbing when we need to use data to test an outcome, but the specifics of the data don't really matter. What...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found