Skip to content

Commit ceb8172

Browse files
committed
Identify TODOs
1 parent 8225f46 commit ceb8172

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/vue-testing-library.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable testing-library/no-wait-for-empty-callback */
2-
import {createLocalVue, mount} from '@vue/test-utils'
2+
import {mount} from '@vue/test-utils'
3+
// import {createLocalVue, mount} from '@vue/test-utils'
34

45
import {
56
getQueriesForElement,
@@ -21,35 +22,38 @@ function render(
2122
} = {},
2223
configurationCb,
2324
) {
25+
// TODO: Can we simplify this by using attachTo?
2426
const div = document.createElement('div')
2527
const baseElement = customBaseElement || customContainer || document.body
2628
const container = customContainer || baseElement.appendChild(div)
2729

2830
const attachTo = document.createElement('div')
2931
container.appendChild(attachTo)
3032

31-
const localVue = createLocalVue()
33+
// const localVue = createLocalVue()
3234
let vuexStore = null
3335
let router = null
3436
let additionalOptions = {}
3537

38+
// TODO: Fix VTL + Vuex (v4?)
3639
if (store) {
3740
const Vuex = require('vuex')
38-
localVue.use(Vuex)
41+
// localVue.use(Vuex)
3942
vuexStore = new Vuex.Store(store)
4043
}
4144

45+
// TODO: Fix VTL + Vue-router(next?)
4246
if (routes) {
4347
const requiredRouter = require('vue-router')
4448
const VueRouter = requiredRouter.default || requiredRouter
45-
localVue.use(VueRouter)
49+
// localVue.use(VueRouter)
4650
router = new VueRouter({
4751
routes,
4852
})
4953
}
5054

5155
if (configurationCb && typeof configurationCb === 'function') {
52-
additionalOptions = configurationCb(localVue, vuexStore, router)
56+
additionalOptions = configurationCb(vuexStore, router)
5357
}
5458

5559
if (!mountOptions.propsData && !!mountOptions.props) {
@@ -58,10 +62,10 @@ function render(
5862
}
5963

6064
const wrapper = mount(TestComponent, {
61-
localVue,
62-
router,
65+
// localVue,
66+
// router,
67+
// store: vuexStore,
6368
attachTo,
64-
store: vuexStore,
6569
...mountOptions,
6670
...additionalOptions,
6771
})
@@ -74,10 +78,14 @@ function render(
7478
baseElement,
7579
debug: (el = baseElement) =>
7680
Array.isArray(el) ? el.forEach(e => logDOM(e)) : logDOM(el),
77-
unmount: () => wrapper.destroy(),
78-
isUnmounted: () => wrapper.vm._isDestroyed,
81+
unmount: () => wrapper.unmount(),
82+
// isUnmounted: () => wrapper.vm._isDestroyed,
7983
html: () => wrapper.html(),
8084
emitted: () => wrapper.emitted(),
85+
86+
// TODO: Is this unnecessary now? No need to await for a tick because
87+
// setProps() handles it for us now.
88+
// We can simply expose setProps.
8189
updateProps: _ => {
8290
wrapper.setProps(_)
8391
return waitFor(() => {})

0 commit comments

Comments
 (0)