Skip to content

Instantly share code, notes, and snippets.

@aptiko
Created May 17, 2021 16:45
Show Gist options
  • Save aptiko/41d6a2186b3854f8f2afe511018d041c to your computer and use it in GitHub Desktop.
Save aptiko/41d6a2186b3854f8f2afe511018d041c to your computer and use it in GitHub Desktop.
Testing store-related Nuxt functionality with mocking
import { mount } from '@vue/test-utils'
import Navbar from '@/components/Navbar.vue'
describe('Navbar', () => {
test('gets loggedOnUser from store', () => {
const wrapper = mount(Navbar, {
mocks: {
$store: { state: { loggedOnUser: 'alice' } },
},
})
expect(wrapper.vm.loggedOnUser).toBe('alice')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment