DEV Community

Discussion on: Whatever happened to the test pyramid?

Collapse
 
patryktech profile image
Patryk

It’s the guidance of preferring integration tests that I am challenging in this post. I’m suggesting that this advice came about not because unit tests don’t make sense on the front-end, but because they often prove extremely difficult for people to get right.

They definitely are. To me, the key reason to write tests is because they add value. If I have code like:

<div v-for="foo in foos">{{ foo.bar }}</div>

writing a test with mocked data feels like I am testing that Vue.js isn't broken and that v-for works. That's Vue's responsibility to test, and I won't bother - it doesn't add value to me.

I may write a test that mocks an API call to make sure it renders everything correctly, but again, that, to me, is an integration test.

I'd be curious to see what you consider a good unit test for frameworks. (I'll be sure to look through your Svelte testing series, even though I am not currently interested in learning another framework - maybe I'll find an answer there.)

I exist in the camp of people that believes that we should always ”minimize” frameworks as much as possible.

I can respect that position. As I'm not good at design, and don't care to spend 2 months writing apps that work well on OSX, and iOS, and Safari, and IE11, etc., I personally like frameworks that offer a lot of abstractions, and let me focus on features. I love working with Quasar (based on Vue). But that's a personal choice, and I don't think there is one good answer - we've all got our own strengths, weaknesses, and preferences.