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

@molgenis/molgenis-vue-test-utils

v1.2.0

Published

Test utilities for Vue and Vuex code

Downloads

121

Readme

molgenis-vue-test-utils

Testing utilities for Vue and Vuex Javascript unit tests

Installation

NPM

npm install @molgenis/molgenis-vue-test-utils --save

Yarn

yarn add @molgenis/molgenis-vue-test-utils

Usage

Import in your HTML

<script src="path/to/molgenis-vue-test-utils.js"></script>

Import as ES6 module

import utils from '@molgenis/molgenis-vue-test-utils'

utils.testAction(...)

CommonJS import

const utils = require('@molgenis/molgenis-vue-test-utils/dist/molgenis-vue-test-utils.js')

utils.testAction(...)

Examples


// actions.js

import api from 'whatever-you-use-as-api'
export const GET_A_NICE_RESPONSE = '__GET_A_NICE_RESPONSE__'

export default {
  [GET_A_NICE_RESPONSE] ({commit}, id) {
    api.get('/api/response/' + id).then(response => {
      commit(SET_RESPONSE, response)
    }
  }
}
 
// actions.spec.js
 
import td from 'testdouble'
import api from 'whatever-you-use-as-api'
import { testAction } from '@molgenis/molgenis-js-test-utils'
import actions from 'store/actions'
 
it('call an api, and call a mutation with the response', done => {
  const response = 'got a nice response'
  
  const get = td.function('api.get')
  td.when(get('/api/response/my_id')).thenResolve(response)
  td.replace(api, 'get', get)
 
  const options = {
    payload: 'my_id',
    expectedMutations: [
      {type: SET_RESPONSE, payload: response}
    ]
  }
  testAction(actions.__GET_NICE_RESPONSE__, options, done)
})

Methods

| Method | Description | |--------|-------------| | utils.testAction(action, options, done) | Test a Vuex action |

Options

The options object that can be supplied to the testAction function can contain the following parameters

| Parameter | Description | Default value | |-----------|-------------|---------------| | payload | a JS object or string or number to pass to the action being tested | null | | state | the state used by the action being tested | {} | | expectedMutations | an array of object{type:..., payload:...} describing all the mutations that are committed by the action being tested | [] | | expectedActions | an array of object{type:..., payload:...} describing all the actions that are dispatched by the action being tested | [] | | getters | an object containing getter functions as keys, and their expected return value as value. Use this to mock getters in your actions | {}

Contributing

This project uses Yarn for development, uses Mocha for testing and is compiled with Rollup

To get started: yarn install

To build: yarn build

To test: yarn test

To test with coverage: yarn test:cover

To get coverage: yarn coveralls

To lint: yarn lint

To debug: first add node-inspector: npm install -g node-inspector then run: yarn debug