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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vuegister

v0.2.2

Published

The require hook for load SFC (single-file component or *.vue) files.

Downloads

31

Readme

vuegister npm version build status

About

Vuegister (a portmanteau for vue-register) is a require hook for loading of the Vue.js single-file components (or *.vue files). The main purpose of this package is to help the developer with unit testing of the component's logic. It allows you to import the object from the *.vue template as you do it with any Node.js module.

Sometimes you want to run multiple small tests simultaneously. Opening a new page with test suite in browser (even in PhantomJS) can take minutes. With the help of jsdom it is possible to speed up this process. You can run your unit tests in the pure Node.js environment. There is no need in heavy test runners (like Karma) or code transpilers (like Babel). Actual versions of Node.js supports new features from the latest revision of the JavaScript ECMA-262 specification. The website node.green provides overview of supported ECMAScript features in various versions of Node.js.

This package doesn't perform any transpiling of the code. Vuegister just extracts text between script tags, adds source map and passes the result to Module.prototype._compile. The module._compile method can only run JavaScript code (not CoffeeScript or Babel dependent). At the same time you can use external plugins for the code transpiling. Please see the Plugins section of this document.

Installation

npm i vuegister -D

Plugins

Vuegister can be easily extended through plugins to support various code preprocessors. Take a look at the babel plugin for further details.

Usage

Register *.vue extension from Node.js:

require('vuegister').register()

Using require hook from the Mocha test framework. This is equivalent to Babel’s babel-register:

mocha --require vuegister/register

Test suite example

To run test suite create test.js and MyComponent.vue files inside your test folder.

Content of the test.js file:

const assert = require('chai').assert;
const Vue = require('vue/dist/vue.common')
const MyComponent = require('./MyComponent.vue')

describe('MyComponent', () => {
  it('has a created hook', () => {
    assert.isFunction(MyComponent.created)
  })

  it('sets the correct default data', () => {
    assert.isFunction(MyComponent.data)
    const defaultData = MyComponent.data()
    assert.strictEqual(defaultData.message, 'hello!')
  })

  it('correctly sets the message when created', () => {
    const vm = new Vue(MyComponent).$mount()
    assert.strictEqual(vm.message, 'bye!')
  })

  it('renders the correct message', () => {
    const Ctor = Vue.extend(MyComponent)
    const vm = new Ctor().$mount()
    assert.strictEqual(vm.$el.textContent, 'bye!')
  })
})

Content of the MyComponent.vue file:

<template>
  <span>{{ message }}</span>
</template>
<script>
  module.exports = {
    data () {
      return {
        message: 'hello!'
      }
    },
    created () {
      this.message = 'bye!'
    }
  }
</script>

Install jsdom-global and run tests with:

npm i jsdom jsdom-global -D
mocha -r jsdom-global/register -r vuegister/register

API Reference

Project documentation is generated automatically from source code. Please take a look at the api.md file in this repository.

Tests

To run the test suite, install development dependencies and execute:

npm run coverage

License

Distributed under MIT License.