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 🙏

© 2025 – Pkg Stats / Ryan Hefner

createlocalvuerouter

v1.0.5

Published

returns a VueRouter class that clears global variables it polluted in a previous import in Node.js

Readme

createLocalVueRouter

returns a VueRouter class that clears global variables it polluted in a previous import in Node.js.

License: MIT

Example

// inside a vue-test-utils vue unit test
// $ npx vue create unit-test-project
// $ cd unit-test-project
// $ vue add @vue/unit-mocha
// $ npm run test:unit

// Create a new unit test with the source code below.
import { expect } from 'chai'
import { shallowMount, createLocalVue } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'
import createLocalVueRouter from 'createlocalvuerouter';

const routes = [
  {
    path: '/',
    name: 'root'
  },
  {
    path: '/home',
    name: 'home'
  },
  {
    path: '/options',
    name: 'options'
  },
  {
    path: '/profile',
    name: 'profile'
  }
];

describe('Vue Router', () => {
  describe('initialize a vue router instance', () => {
    it('should default to root route name', () => {
      const localVue = createLocalVue()
      const VueRouter = createLocalVueRouter();
      localVue.use(VueRouter)
      const router = new VueRouter({routes})
      const wrapper = shallowMount(HelloWorld, { localVue, router})
      const actual = wrapper.vm.$router.currentRoute.name
      const expected = 'root'
      expect(actual).to.equal(expected)
    })
    describe('when navigating', () => {
      it("should be able to access home", () => {
        const localVue = createLocalVue()
        const VueRouter = createLocalVueRouter();
        localVue.use(VueRouter)
        const router = new VueRouter({routes})
        const wrapper = shallowMount(HelloWorld, { localVue, router})
        wrapper.vm.$router.push('home')
        const actual = wrapper.vm.$router.currentRoute.name
        const expected = 'home'
        expect(actual).to.equal(expected)
      })
      it("should be able to access options from root path", () => {
        const localVue = createLocalVue()
        const VueRouter = createLocalVueRouter();
        localVue.use(VueRouter)
        const router = new VueRouter({routes})
        const wrapper = shallowMount(HelloWorld, { localVue, router})
        const currentRouteName = wrapper.vm.$router.currentRoute.name
        expect(currentRouteName).to.equal('root')
        wrapper.vm.$router.push('options')
        const actual = wrapper.vm.$router.currentRoute.name
        const expected = 'options'
        expect(actual).to.equal(expected)
      })
    })
  })
})

Unit testing

This library should be used with vue test utils to allow for independent testing of the VueRouter class in unit tests.

Similar to createLocalVue I wanted to make a createLocalVueRouter to be able to test seperate VueRouter instances across unit tests.

Try for yourself, go through the CLI commands in the source code above and replace the import statement with import VueRouter from "vue-router" and see the last unit test fail because of global variables being edited.

i.g.

// swap this import
import createLocalVueRouter from 'createlocalvuerouter';

// for this import
import VueRouter from 'vue-router';

// The last unit test will fail.

Usage

npm install createlocalvuerouter

See it out on npm here

Installation

This will allow you to locally develop the code.

Clone

Clone https://github.com/nadr0/createLocalVueRouter to your machine

Setup

We need to install all the dependencies for you to compile the source code into the distribution source.

npm install

Usage

source/index.js file is all the source code of the library. Import it into whatever application you want.

Code Structure

All the source for the library is in source/index.js.

Documentation

import createLocalVueRouter from 'createlocalvuerouter';
const VueRouter = createLocalVueRouter();

Contributing

Feel free, make some issues make some PRs.

Support

Reach out to me at one of the following places

  • Website at kevinnadro.com

License

License: MIT