npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-box

v1.3.0

Published

A Small module that pull vue components into a simple testable environment for methods, computed props, and watched functionality

Downloads

16

Readme

Build Status

Vue Box

Grabs your vue file, turns it into standing JS and gives you back the object to run your tests against

Please report any issues as soon as you can, I am one man and cannot test every need, or situation thank you! Please Feel free to leave suggestions on improvements/methods you'd want to see added. OR feel free to send a PR!

Changelog

You can find the changelog here: https://github.com/dhershman1/vue-box/blob/master/changelog.md

Params

  • options: Object - An object of options to help Vue Box

Options

const defaults = {
	props: {}, // Props used in any of your components
	vuePath: '/', // The path to the vue file your currently testing
	componentPath: '/', // the path to where your components live
	testName: 'default', // Name of the current test (optional)
	outputDir: 'tests', // Specify where you want the ouput dir to be
	external: [], // Array of external modules E.G underscore
	globals: {} // An object of globals E.G { underscore: '_' }
};

How It Works

So obviously Vue-Box isn't using a browser environment the whole purpose of this is to give you a unit testing environment to run your javascript tests.

Well the cons to doing this is we don't exactly use Vue itself since it would yell at us for not having a browser, what Vue-Box is doing is eliminating the this scope from vue by applying your props and data values to your computed, and method objects. It even creates a fake event catcher for $emit

How To

Pass in a set of options to vueBox and go from there

For single vue files (not importing other vue components)

const vueBox = require('vue-box');
vueBox({
	vuePath: `${__dirname}/../index.vue`,
	outputDir: 'tests',
	testName: 'Single-Component',
	externals: ['underscore'],
	globals: {
		underscore: '_'
	}
}).then(vm => {
	// You can now access your vue object here
});

For a vue file that is importing other vue components

const vueBox = require('vue-box');
vueBox({
	vuePath: `${__dirname}/../index.vue`,
	outputDir: 'tests',
	testName: 'Import-Component',
	componentPath: `${__dirname}/../../`, // Note a path that points to the general components directory
	externals: ['underscore'], // General rollup settings
	globals: { // More general rollup settings
		underscore: '_'
	}
}).then(vm => {
	// You can now access your vue object here
	// Your main vue file will be under default so:
	vm.default.data() // etc...
	// You can also look at other components if you need too through the vm variabel
});

Checking Changes In Data

You can watch for changes in data based on the area you are in, methods will change data in the method scope for instance

// If we have a method like this inside our .vue file
testMethod() {
	this.dataValue = 'new value';
}

// While in our test file we will have something like:
const vueBox = require('vue-box');
vueBox({
 // Options
}).then(vm => {
	vm.methods.testMethod();
	console.log(vm.methods.dataValue);
	// Output:
	// 'new value'
});