explaingit

posva/vuex-mock-store

Analysis updated 2026-08-03 · repo last pushed 2026-08-03

271JavaScriptAudience · developerComplexity · 2/5ActiveSetup · easy

TLDR

A lightweight fake version of Vuex for Vue.js apps that lets you test components in isolation without running your real data store, with built-in spies to verify your component sends the right signals.

Mindmap

mindmap
  root((repo))
    What it does
      Fake Vuex store
      Spies for actions
      Hardcoded getter values
    Tech stack
      JavaScript
      Vue.js
      Vuex
      Jest
    Use cases
      Test shopping cart button
      Verify component signals
      Isolate component tests
    Audience
      Vue developers
      Test-focused devs
    Tradeoffs
      No real getter functions
      Values must be hardcoded

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Test that clicking an add-to-cart button triggers the right Vuex action without running real store logic.

USE CASE 2

Verify a component reads the correct data from Vuex by hardcoding the expected values in a fake store.

USE CASE 3

Check that your component commits the right mutation when a user interacts with it, using built-in spies.

USE CASE 4

Run fast component tests in isolation by replacing the real Vuex store with a lightweight mock.

What is it built with?

JavaScriptVue.jsVuexJest

How does it compare?

posva/vuex-mock-storesindresorhus/cat-namesgaearon/react-blessed-hot-motion
Stars271275276
LanguageJavaScriptJavaScriptJavaScript
Last pushed2026-08-032024-04-302017-11-17
MaintenanceActiveDormantDormant
Setup difficultyeasyeasymoderate
Complexity2/51/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

In plain English

When you're building a Vue.js app, you often use a tool called Vuex to manage shared data across your components. When it comes time to write automated tests for those components, you usually don't want to run your real Vuex setup, because that drags in extra complexity and makes tests slower. This project solves that problem by giving you a lightweight, fake version of Vuex, often called a "mock", so you can test your components in isolation. The way it works is straightforward: you create a fake store and tell it exactly what data and computed values (getters) your component should see. It also automatically sets up monitors, called "spies", that watch whenever your component tries to change data or trigger an action. In your test, you can then simply check if the right button click sent the right signal, without actually executing the real logic behind it. This is useful for developers who want fast, reliable tests and don't want to worry about their Vuex logic breaking their component tests. For example, if you have a shopping cart counter component and want to verify that clicking the "add" button triggers an update, you can test that interaction directly. You focus only on whether the component asked the store to do something, rather than testing the entire store logic at the same time. A notable tradeoff is that this mock doesn't let you provide real functions for your getters, you must provide the exact value the getter should return. The creator intentionally made this choice: if you're testing a specific component, you already know the expected result, and hardcoding that value ensures your test stays completely focused and predictable.

Copy-paste prompts

Prompt 1
Help me set up a vuex-mock-store for a Vue component test where clicking a button should dispatch an action called 'addToCart' with a product id.
Prompt 2
Write a test using vuex-mock-store that verifies my component displays a cart count from a Vuex getter, with the getter value hardcoded to 3.
Prompt 3
Show me how to assert that a component commits a Vuex mutation called 'INCREMENT' when a button is clicked, using vuex-mock-store spies.
Prompt 4
Create a vuex-mock-store instance with state containing a user object and a getter called 'isLoggedIn' that returns true, then show how to pass it to a Vue component in a test.

Frequently asked questions

What is vuex-mock-store?

A lightweight fake version of Vuex for Vue.js apps that lets you test components in isolation without running your real data store, with built-in spies to verify your component sends the right signals.

What language is vuex-mock-store written in?

Mainly JavaScript. The stack also includes JavaScript, Vue.js, Vuex.

Is vuex-mock-store actively maintained?

Active — commit in last 30 days (last push 2026-08-03).

How hard is vuex-mock-store to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is vuex-mock-store for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.