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

  • 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)
  })
})

About this issue

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

Commits related to this issue

Most upvoted comments

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!