vue-test-utils

Suppress Vue warnings in unit tests

邮差的信 提交于 2020-08-06 10:37:06
问题 I am trying to suppress my warnings in my tests following the config listed here: https://vue-test-utils.vuejs.org/api/config.html#silent, which is as follows: import { config } from '@vue/test-utils'; // this should actually be the default but the default is not working config.silent = true; However, I am still seeing the warning in the test results: TheQueue ✓ should show the queue bar if there are items queued ✓ should show the correct count of queued items in queued bar [Vue warn]: Avoid

Suppress Vue warnings in unit tests

别来无恙 提交于 2020-08-06 10:36:53
问题 I am trying to suppress my warnings in my tests following the config listed here: https://vue-test-utils.vuejs.org/api/config.html#silent, which is as follows: import { config } from '@vue/test-utils'; // this should actually be the default but the default is not working config.silent = true; However, I am still seeing the warning in the test results: TheQueue ✓ should show the queue bar if there are items queued ✓ should show the correct count of queued items in queued bar [Vue warn]: Avoid

Suppress Vue warnings in unit tests

笑着哭i 提交于 2020-08-06 10:36:45
问题 I am trying to suppress my warnings in my tests following the config listed here: https://vue-test-utils.vuejs.org/api/config.html#silent, which is as follows: import { config } from '@vue/test-utils'; // this should actually be the default but the default is not working config.silent = true; However, I am still seeing the warning in the test results: TheQueue ✓ should show the queue bar if there are items queued ✓ should show the correct count of queued items in queued bar [Vue warn]: Avoid

how to mock navigator.clipboard.writeText in vue test utils

。_饼干妹妹 提交于 2020-06-29 04:08:10
问题 I'm trying to test copy to clipboard in nuxt, but test case can't cover navigator.clipboard.writeText , how to test navigator stuff, i also have tried shallowMount and mount but both not working, <template> <span v-b-tooltip.hover class="url" title="Copy" data-test="copyUrl" @click="handleCopy(listing.url)"> <i class="fa fa-copy" aria-hidden="true"/> </span> </template> <script> export default { ............ methods: { .............. handleCopy(url) { navigator.clipboard.writeText(url); } ...

TypeError: Cannot read property 'getters' of undefined

孤街醉人 提交于 2020-06-12 07:01:13
问题 I'm trying to test a basic Vue Component that makes reference to a Vuex store. I thought I followed Vue's example (https://vue-test-utils.vuejs.org/guides/using-with-vuex.html#mocking-getters) to a T but it doesn't appear to be working. I get the error that is mentioned in the title. const localVue = createLocalVue() localVue.use(Vuex) describe('Navbar.vue', () => { let store: any let getters: any beforeEach(() => { getters: { isLoggedIn: () => false } store = new Vuex.Store({ getters }) })

What are “stubbed child components” in Vue Test Utils?

徘徊边缘 提交于 2020-04-08 09:33:53
问题 Vue Test Utils has an API method called shallowMount() that: ...creates a Wrapper that contains the mounted and rendered Vue component, but with stubbed child components. I've searched the Vue Test Utils documentation website but failed to find a good explanation of how these stubbed child components behave. What exactly are these stubbed child components? Which parts of the Vue component lifecycle do they go through? Is there a way to pre-program their behavior? 回答1: What exactly are stubbed