Movatterモバイル変換


[0]ホーム

URL:


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

Additional jest matchers for vue

License

NotificationsYou must be signed in to change notification settings

14nrv/jest-vue-matcher

Repository files navigation

NPM VersionBuild StatusTest CoverageMaintainabilityLicense: MITsemantic-releasePRs Welcome

jest-vue-matcher

Additional jest matchers for vue

Install

yarn add jest-vue-matcher -D

Setup

import{mount}from'@vue/test-utils'importmatchersfrom'jest-vue-matcher'importMyComponentfrom'@/components/MyComponent.vue'letwrapperdescribe('MyComponent',()=>{beforeEach(()=>{wrapper=mount(MyComponent)expect.extend(matchers(wrapper))})// ...})

Matchers available

  • toHaveText(text)
    expect('h1').toHaveText('My title')expect('h1').not.toHaveText('Not my title')
  • toBeADomElement()
    expect('h1').toBeADomElement()expect('notH1').not.toBeADomElement()
  • toHaveClass(className)
    expect('h1').toHaveClass('title')expect('h1').not.toHaveClass('not-title')
  • toHaveAttribute(attributeName, attributeValue)
    expect('h1').toHaveAttribute('class','title')expect('h1').not.toHaveAClass('class','not-title')
  • toHaveValue(value)
    expect('input[type=text]').toHaveValue('plop')expect('input[type=text]').not.toHaveValue('not plop')
  • toHaveProp(propName)
    expect(wrapper).toHaveProp('propName')expect(wrapper).not.toHaveProp('not-propName')
  • toEmit(eventName)
    expect(wrapper).toEmit('eventName')expect(wrapper).not.toEmit('not eventName')
  • toEmitWith(eventName, eventValue)
    expect(wrapper).toEmitWith('eventName','eventValue')expect(wrapper).not.toEmitWith('not eventName',{data:'eventValue'})

Inspiration

Inspirated bymwangaben-vthelpers

About

Additional jest matchers for vue

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp