1. karma-vue-component
a tiny wrapper to load a vue-component with one function call
karma-vue-component
Package: karma-vue-component
Created by: paulpflug
Last modified: Sun, 19 Jun 2022 08:07:22 GMT
Version: 2.0.2
License: MIT
Downloads: 28
Repository: https://github.com/paulpflug/karma-vue-component

Install

npm install karma-vue-component
yarn add karma-vue-component

karma-vue-component

To fasten the testing of Vue components.
karma-vue-component is a tiny wrapper to load a vue-component with one function call.

Install

npm install --save-dev karma-vue-component
// [email protected]
npm install --save-dev karma-vue-component@1

add 'vue-component' to the frameworks in the karma.conf

What it does

  • Loads Vue as global

  • adds the functions loadComp and unloadComp as globals

 loadComp = function(comp, data) {
  comp = Vue.extend(comp);
  comp = new comp(data);
  document.body.appendChild(comp.$mount().$el);
  return comp;
};

unloadComp = function(comp) {
  document.body.removeChild(comp.$el);
  return comp.$destroy();
};

Usage

 // for example with webpack
comp = loadComp(require("../dev/someComp.vue"))

Changelog

  • 2.0.0
    compatible to vue@2

  • 1.0.0
    added data argument to loadComp

License

Copyright (c) 2016 Paul Pflugradt
Licensed under the MIT license.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin