Last active
April 8, 2022 11:05
-
-
Save eddyerburgh/918af21eb465eba04b8401f2063124f8 to your computer and use it in GitHub Desktop.
vue-test-utils hasClass example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mount } from 'vue-test-utils' | |
import Component from '@/components/ComponentToTest' | |
const wrapper = mount(ComponentToTest) | |
// Traversal | |
const Foo = wrapper.find(Foo) | |
const divs = wrapper.findAll('div') | |
const div = divs.at(0) | |
// Actions | |
Foo.setData({ foo: true }) | |
Foo.setProps({ bar: true }) | |
div.trigger('click') | |
// Assertions | |
expect(Foo.hasProp('bar', 'foobar')).toBe(true) | |
expect(div.hasClass('foo')).toBe(true) | |
expect(div.hasStyle('color', 'red')).toBe(true) | |
expect(div.is('.foo')).toBe(true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Uthpala