Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vue-testing-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ function render(
wrapper.setProps(_)
return wait()
},
...(store ? { store: vuexStore } : {}),
...(routes ? { router } : {}),
...getQueriesForElement(wrapper.element.parentNode)
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/__tests__/vue-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ const routes = [

afterEach(cleanup)

test('router instance available', async () => {
const { queryByTestId, router } = render(App, { routes })
expect(router.currentRoute.path).toBe('/')
await fireEvent.click(queryByTestId('about-link'))
expect(router.currentRoute.path).toBe('/about')
})

test('full app rendering/navigating', async () => {
// Notice how we pass a `routes` object to our render function.
const { queryByTestId } = render(App, { routes })
Expand Down
7 changes: 7 additions & 0 deletions tests/__tests__/vuex.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ test('can render with vuex with custom store', async () => {

expect(console.error).toHaveBeenCalled()
})

test('vuex store instance available to programmatically fire actions', () => {
const { store } = renderVuexTestComponent()
expect(store.state).toEqual({ count: 1 })
store.dispatch('increment')
expect(store.state).toEqual({ count: 2 })
})