Skip to content

Instantly share code, notes, and snippets.

@eddyerburgh
Last active September 30, 2018 04:45
Show Gist options
  • Save eddyerburgh/2767f3d18ab39bea70d4484a8992293d to your computer and use it in GitHub Desktop.
Save eddyerburgh/2767f3d18ab39bea70d4484a8992293d to your computer and use it in GitHub Desktop.
import { mount } from '@vue/test-utils'
import MessageToggle from '@/components/MessageToggle.vue'
describe('MessageToggle.vue', () => {
it('displays default message', () => {
const wrapper = mount(MessageToggle)
expect(wrapper.text()).toContain('default message')
})
it('toggles message when button is clicked', () => {
const wrapper = mount(MessageToggle)
const button = wrapper.find('#toggle-message')
const p = wrapper.find('p')
button.trigger('click')
expect(p.text()).toBe('message')
button.trigger('click')
expect(p.text()).toBe('toggled message')
})
})
@EmilyRosina
Copy link

EmilyRosina commented Apr 24, 2018

Hey, just going through your tutorial on freeCodeCamp - thank you, it's awesome!
Did notice one hiccup for me though:

import { mount } from 'vue-test-utils' should be import { mount } from '@vue/test-utils'

same issue found here:
here, here and here

@eddyerburgh
Copy link
Author

Thanks, I'm updating them all now 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment