Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cheatsheet/examples of all kind of vue unit tests

dcrystalj/vue-testing-examples

Repository files navigation

covered examples:

  • unit
    • rendered component output
      • text content
      • dom attributes
      • how many components are rendered
      • classes
      • style
      • component props
    • mocks
      • timer functions
      • mock module dependencies
      • async code
    • events
      • native dom events (clicks)
      • custom vue event
        • component emits event
        • component listen for event
    • vue router
    • mixins
      • local
      • global
    • filters
    • forms
      • input forms
      • control inputs
      • radio buttons
    • factory
      • store factory
      • wrapper factory
    • vuex
      • test as instance
      • or seperatly
        • mutations
        • getters
        • actions
      • vuex in components
    • server side rendering (TODO)
  • integration
    • not needed
  • snapshots
  • end 2 end tests (TODO)
    • for routes
    • for dynamic data
    • multiple browsers

recomended test flow

what to test?

  • the input could be:
    • Component props
    • User actions (like a button click)
    • Vue events
    • Data in a Vuex store
  • Forms of output for a Vue component could be:
    • rendered text
      • Only test output that is dynamically generated
      • Only test output that is part of the component contract
    • Emitted events
    • External function calls

jsdom limitations

  • layout (element positions)
  • navigation (submit form)

test coverage

enable in jest.config.js

debugging

  • run yarn test:unit:debug
  • open chrome://inspect in chrome browser

dependencies

list of dependencies added after vue project is created with default settings:

references

  • testing vue.js applications (Edd Yerburgh)
  • vue test utils docs
  • vue testing docs
  • vuex testing docs
  • jest docs

About

Cheatsheet/examples of all kind of vue unit tests

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /