Reputation: 253
I have the following code:
this.$vs.loading()
....
this.$vs.loading.close()
I need to pass a mock to shallowMount like this:
const vs = {
loading: jest.fn()
}
mocks: {
$vs: vs
}
But how can I mock loading
and close
?
Using loading: jest.fn()
, I just mock loading()
. How do I mock close()
inside the loading
property?
Upvotes: 5
Views: 4991
Reputation: 138656
You can attach the mocked property to the mock function itself:
const vs = {
loading: jest.fn()
}
vs.loading.close = jest.fn()
Upvotes: 5