0
0
Vueframework~5 mins

Mocking composables and stores in Vue - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ATo add new features to the composable
BTo improve component styling
CTo increase app performance in production
DTo isolate component tests from real composable logic
Which Vue store library is commonly mocked using 'createTestingPinia'?
APinia
BVuex
CRedux
DMobX
When mocking a composable, what should the mock return?
ARandom values each time
BThe original composable's code
CFixed or controlled reactive values
DNothing at all
Which Vue API is most relevant when mocking composables?
AComposition API
BOptions API
CVue Router
DVue CLI
Mocking stores helps tests by:
AMaking tests slower
BRemoving side effects and dependencies
CChanging production code
DAdding network calls
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.