Fix: Vue's nextTick doesn't wait for jest mocks to resolve

This commit is contained in:
Raphael Beer 2020-03-23 12:45:55 +01:00
parent 801eb1e515
commit 0b916012e8
No known key found for this signature in database
GPG Key ID: C1AC5E018B25EF11

View File

@ -59,9 +59,14 @@ describe('FollowList.vue', () => {
expect(wrapper.findAll('.user-teaser').length).toEqual(user[type].length)
})
it(`has a button to load all remaining users ${type}`, async () => {
jest.useFakeTimers()
wrapper.find('button').trigger('click')
//await wrapper.vm.$nextTick()
//expect(wrapper.vm.connections.length).toBe(user[`${type}Count`])
await jest.runAllTicks()
await wrapper.vm.$nextTick()
expect(wrapper.vm.connections.length).toBe(user[`${type}Count`])
expect(queryMock).toHaveBeenCalledWith({
query: wrapper.vm.queries[type],
variables: { id: user.id },