From 0b916012e81f297db7701321d5753517589a98f5 Mon Sep 17 00:00:00 2001 From: Raphael Beer Date: Mon, 23 Mar 2020 12:45:55 +0100 Subject: [PATCH] Fix: Vue's nextTick doesn't wait for jest mocks to resolve --- webapp/components/features/FollowList.spec.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webapp/components/features/FollowList.spec.js b/webapp/components/features/FollowList.spec.js index 0ba253734..602d004bc 100644 --- a/webapp/components/features/FollowList.spec.js +++ b/webapp/components/features/FollowList.spec.js @@ -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 },