D
D
Dmitry Ivchenkov2020-06-23 22:48:00
Software testing
Dmitry Ivchenkov, 2020-06-23 22:48:00

How to automatically generate tests for all vue components?

There is an application on vue, I set up basic configs, linters, git hooks and that's it.
There is no paid time allocated for the tests. But without tests, the whole application will grow into one big (giant) pain. I want to stop her a little.

I'm sure there are tools to generate test files for each component. At least it's simple whether the component is rendered or not (with an error).
Or. for example, there are multiple events, hover and click. And the test checks the work of the handler when the event fires.

In fact, in a test, this is boilerplate: trigger an event and check the result (for example, as in the docs: https://vue-test-utils.vuejs.org/guides/#testing-k...

Googled that this is called "coverage tests", but to automatically - nothing.

Not to check completely all application after each minimum editing.

In general, is it possible to somehow automatically cover the existing components with tests through the console command?

The meaning of my question is to go through all the components with a tool, check the test coverage, and if there is none for the component, generate it. Is there such a thing, is it possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-06-24
@Dzmitryj_Black

Look towards testing with snapshots. It seems that jest can, I don’t know how it works with vue.
But in general:

Not to check completely all application after each minimum editing.

If your application is written correctly, then the minimum editing in the component should only affect the logic of this component (if you have not changed its external api, then this will affect others, but the chance that this will break their logic is minimal).
Therefore, yes - do not check everything, after each edit you only need to check this component itself. If you have components not for 1000 lines, then most likely you will check everything during the development process.
If more formally - that is, a storybook, where you generally develop each component separately, in isolation and check it in essence during the development process. It allows you to explicitly describe the different states of the component and quickly check them.
In general, the importance of testing for UI components is extremely exaggerated, IMHO. Most of the failed tests in yuai are not because they caught some kind of bug, but because the logic has changed and the tests need to be corrected. This is exactly the case when the tests work in the red and in yuai its share is extremely large.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question