DEV Community

Discussion on: Does your team write code tests for front-end code?

Collapse
 
manuelbarzi profile image
manuelbarzi • Edited

If the "CORE THING" of an application is well tested, and with that I mean the most important part: The Business Layer (and its inner Data Layer). Then focussing on testing the upper layers (UI, Front, UI Components...) is for sure good. But only to be relevant once FIRST the inner layers are widely tested (Business and Data).

And this implies front-end and back-end. If you are following a proper architecture, for instance, in a client-server projection for an SPA consuming an API, where you have created an abstraction of your Business Layer in both the client and the server sides, following a correct Separation of Concerns, and isolated, then that should be the initial target to test.

[Front-end] -> [Logic (business)] -> [API clients] ··· (XHR / HTTP) ···> [Back-end] -> [Logic (business)] -> [Data]

And once having fully assured those Logic (business) components are fully tested, then proceed to bring effort on pure UI / Front / Components testing.

This principle also follows the way of thinking of the Test Pyramid, in which not only deciding which parts of a software should be tested first is important, but what's the effort and COST on them. For sure, testing the inner-lower layers (Business, Data) requires a lot of coding, but in general is much more faster and secure to first being compliance with that, and later on with the upper layers.

Here's also a good article that concerns on this: The Practical Test Pyramid