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:
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:
- Created 5 years ago
- Reactions:1
- Comments:21 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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!
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.