Skip to content
This repository was archived by the owner on Dec 12, 2020. It is now read-only.

Commit dfffa0a

Browse files
committed
chore: trying to figure out why #43 happens
1 parent e2e9791 commit dfffa0a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cypress/integration/ajax-list-spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1+
/// <reference types="cypress" />
2+
'use strict'
3+
14
import AjaxList from '../../components/AjaxList.vue'
25
const mountVue = require('../..')
36

47
/* eslint-env mocha */
58
describe('AjaxList', () => {
6-
beforeEach(mountVue(AjaxList))
9+
// because this component loads data right away
10+
// we need to setup XHR intercepts BEFORE mounting it
11+
// thus each test will first do its "cy.route"
12+
// then will mount the component
713

814
it('loads list of posts', () => {
915
// now we can observe the XHR to the server
1016
cy.get('li').should('have.length', 3)
1117
})
1218

19+
1320
it('can inspect real data in XHR', () => {
1421
cy.server()
1522
cy.route('/users?_limit=3').as('users')
23+
mountVue(AjaxList)()
24+
1625
cy.wait('@users').its('response.body').should('have.length', 3)
1726
})
1827

28+
1929
it('can display mock XHR response', () => {
2030
cy.server()
2131
const users = [{id: 1, name: 'foo'}]
2232
cy.route('GET', '/users?_limit=3', users).as('users')
33+
mountVue(AjaxList)()
34+
2335
cy.get('li').should('have.length', 1)
2436
.first().contains('foo')
2537
})
@@ -28,6 +40,8 @@ describe('AjaxList', () => {
2840
cy.server()
2941
const users = [{id: 1, name: 'foo'}]
3042
cy.route('GET', '/users?_limit=3', users).as('users')
43+
mountVue(AjaxList)()
44+
3145
cy.wait('@users').its('response.body').should('deep.equal', users)
3246
})
3347

@@ -40,6 +54,8 @@ describe('AjaxList', () => {
4054
response: users,
4155
delay: 1000
4256
}).as('users')
57+
mountVue(AjaxList)()
58+
4359
cy.get('li').should('have.length', 0)
4460
cy.wait('@users')
4561
cy.get('li').should('have.length', 1)

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference types="cypress" />
2+
13
const Vue = require('vue/dist/vue')
24
const { stripIndent } = require('common-tags')
35

0 commit comments

Comments
 (0)