elr-vue-jest-helpers

some helpers for testing Vue apps with Jest

Usage no npm install needed!

<script type="module">
  import elrVueJestHelpers from 'https://cdn.skypack.dev/elr-vue-jest-helpers';
</script>

README

ELR Vue Test Helpers

A small library of test methods to speed up Vue component testing

Build Status License: MIT npm

For use with VueTestUtils and Jest

npm install elr-vue-jest-helpers --save-dev

or

yarn add elr-vue-jest-helpers -D

import helpers from 'elr-vue-jest-helpers';

Initialize the helpers library after you mount your wrapper component pass in the Vue component instance pass in the expect method from Jest all methods are chainable

h.init({wrapper, expect});

*** if you mount your component again you must reinitialize the test utilities so they can interact with your new wrapper.

Methods

  • select
    • select an option in a select form field
h.select('California', '#states');
  • type
    • type some input into a form field
  • blur
    • trigger blur event on form field
  • submit
    • trigger a submit event on a form field
  • clear
    • clear value from form field
  • click
    • trigger a click event
  • emit
    • test that an event is emitted
  • doesNotEmit
    • test that an event is not emmitted
  • payloadEquals
    • check the content of an event payload
  • contains
  • doesNotContain
  • matches
  • see
  • html
  • hasStyle
  • isHidden
  • isValidInput
  • isInvalidInput
  • hasCount
  • hasClass
  • notToHaveClass
  • isDisabled
  • isNotDisabled
  • text