Install ORACLE JDK 8 on Ubuntu

This is the latest stable version of Java 8 at time of writing, and the recommended version to install. You can do so using the following command: Open /etc/environment file with your favorite text…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to test a vuex plugin without vuex dependencies

“TLDR;”
Create a mock vuex-store and subscribe and fire events manually

So for this short example we will write a really small implementation of a vuex plugin. I want this plugin to throw an error if the payload has a trigger property set to true. And if not I want it to do nothing.

This is really quite simple and nothing special. But of course this is just a simple plugin and only limited by your imagination.

And that is really all there is to it. Now you have a mockStore you can use in your tests.

And that’s how simple it is to test a vuex plugin. I hope this will help someone in the future. It was sure fun to write tests for the before mentioned repo and learned a lot about how the vuex store works. To end with a nice example I have setup a codesandbox in which you can see all the code.

Add a comment

Related posts:

Unifying Language

While I was waiting for my coffee on Monday, I had the good fortune to browse through that wonderful publication called the Australian Financial Review. For those of you who don’t know about the AFR…

Short Story Mechanics

I live and breathe short fiction every day. Reading submissions for Clarkesworld, running a critique group, and writing my own pieces has me up to my eyeballs in stories under 16,000 words. All the…

The Doctor is Calling

Copper is often referred to as the metal with a Ph.D. Because of its broad range of industrial uses, Dr. Copper has a well-deserved reputation as a predictive indicator for global macroeconomic…