Testing of Vue pages

problem description

want to unit test the current project, expect to test for a single problem, test content behavior test, method test, simple UI test

the environmental background of the problems and what methods you have tried

because I am not familiar with testing. Refer to the test code of the official website and open source component library for development. But it is found that tests have a variety of dependencies. For example,

A.vue introduces components B.vue , B.vue contains xx.js business scripts, and then xx.js refers to the common library util.js , and A.vue contains store of vuex . Then they are interlinked and report all kinds of mistakes.

is it possible to remove some of the dependencies and test them only?

Mar.25,2021

There are three main ways of

.

one is module mock (module emulation), which simulates the module to simulate its api, without simulating the implementation.

the second is shallow render that uses vue (and of course react is the same). This does not render the subcomponent

third, the code is split, or only some methods are tested (or even private methods can be tested), not all.

I hope my answer can help you.

Menu