Recall & Review
beginner
What is mocking in the context of Vue composables and stores?
Mocking means creating fake versions of composables or stores to test components without using real data or logic. It helps isolate parts during testing.
Click to reveal answer
beginner
Why do we mock composables or stores in Vue tests?
We mock them to control their behavior, avoid side effects, and test components independently from actual data or network calls.
Click to reveal answer
intermediate
How can you mock a composable in Vue 3 using the Composition API?
You can replace the composable import with a mock function that returns fixed values or reactive refs during tests.Click to reveal answer
intermediate
What is a common tool to mock Pinia stores in Vue tests?
Pinia stores can be mocked by creating a fake store instance or using testing utilities like 'createTestingPinia' to simulate store behavior.
Click to reveal answer
beginner
How does mocking improve test reliability in Vue applications?
Mocking removes dependencies on real data or APIs, making tests faster, more predictable, and easier to debug.
Click to reveal answer
What is the main purpose of mocking a composable in Vue tests?
✗ Incorrect
Mocking isolates tests by replacing real composable logic with controlled fake data.
Which Vue store library is commonly mocked using 'createTestingPinia'?
✗ Incorrect
'createTestingPinia' is a utility for mocking Pinia stores in tests.
When mocking a composable, what should the mock return?
✗ Incorrect
Mocks return fixed or controlled reactive values to simulate expected behavior.
Which Vue API is most relevant when mocking composables?
✗ Incorrect
The Composition API is used to create and mock composables.
Mocking stores helps tests by:
✗ Incorrect
Mocking removes side effects and external dependencies, improving test reliability.
Explain how you would mock a Pinia store in a Vue 3 test.
Think about how to isolate store logic from the component during testing.
You got /4 concepts.
Describe why mocking composables is useful when testing Vue components.
Consider what problems mocking solves in testing.
You got /4 concepts.