DEV Community

Discussion on: Should I use Testing?

Collapse
 
guledali profile image
guledali

Should I write tests?

If I was doing testing for frontend, I would seriously look into cypress for most things and only reach for other testing framework for more logic related stuff. For example view-helpers in javascript that you have for formatting date and what not. Use jest or other unit testing frameworks for that.

Collapse
 
guledali profile image
guledali • Edited

It depends what kind of test you're written but you should make sure you writing meaningful tests. For example I have seen a lot react test that testing that the component renders that's it.


describe('Header', () => {
  it('renders the Header component', () => {

    expect(render(<Header text={ title: 'Foobar' } />)).toEqual('<header>Foobar</header>')
  })
})

Enter fullscreen mode Exit fullscreen mode

I don't like those kinda of tests, I would prefer acceptance tests, for most front-end related stuff and reach for unit-test only when I need it