Book Image

Vue.js 2 Cookbook

By : Andrea Passaglia
Book Image

Vue.js 2 Cookbook

By: Andrea Passaglia

Overview of this book

Vue.js is an open source JavaScript library for building modern, interactive web applications. With a rapidly growing community and a strong ecosystem, Vue.js makes developing complex single page applications a breeze. Its component-based approach, intuitive API, blazing fast core, and compact size make Vue.js a great solution to craft your next front-end application. From basic to advanced recipes, this book arms you with practical solutions to common tasks when building an application using Vue. We start off by exploring the fundamentals of Vue.js: its reactivity system, data-binding syntax, and component-based architecture through practical examples. After that, we delve into integrating Webpack and Babel to enhance your development workflow using single file components. Finally, we take an in-depth look at Vuex for state management and Vue Router to route in your single page applications, and integrate a variety of technologies ranging from Node.js to Electron, and Socket.io to Firebase and HorizonDB. This book will provide you with the best practices as determined by the Vue.js community.
Table of Contents (19 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Adding some Karma to your workflow


Karma is a JavaScript test runner. This means that it will run your tests for you. Software often grows quickly and Karma gives you a way to run all your unit tests at once. It also gives you the power to add tools that monitor for test coverage and code quality.

Karma is used traditionally in Vue projects and is present in the official Vue templates as a tool. Learning Karma is a great addition for your JavaScript toolbelt even if you are not working with Vue.

Getting ready

I would consider having completed the Using Jasmine for testing Vue recipe a prerequisite. Since Karma is a test runner, you should first be able to write a test.

We will use npm in this recipe, so you should first read the basics on how to use it in the Choosing a development environment recipe.

 

How to do it...

For this recipe, we will need the command line and npm, so be sure to have it installed before moving ahead.

In a new folder, create a file named package.json and write the following...