Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How I met your coverage threshold

How I met your coverage threshold

From Frontend Connect 2017 in Warsaw, Poland.

We’ve all been there. Front-end testing is a difficult challenge everyone faces, and lots of people tend to run away from. More often than not it’s fragile, brittle, and even useless.

In this presentation, Louay will talk about his experience in creating a team culture and a toolset that facilitates writing front-end tests for developers which are valuable and less fragile & flakey.

He’ll also discuss some tools and best practices that help with tracking and increasing tests and test coverage.

Louay Alakkad

September 23, 2017
Tweet

More Decks by Louay Alakkad

Other Decks in Programming

Transcript

  1. Disclaimer: This talk has nothing to do with the TV

    show How I Met Your Mother Any similarities between them are a figment of your imagination
  2. HOW I MET YOUR COVERAGE THRESHOLD SOME BACKGROUND ▸ Born

    and grew up in Syria, lived and worked in the UAE, Jordan, Turkey, the UK, Germany, and Latvia ▸ My job is to help big businesses deliver products faster and with higher quality ▸ My favourite city is (still) İstanbul. ▸ Aaaand having said that, you should follow catsofistanbul on Instagram ;)
  3. HOW I MET YOUR COVERAGE THRESHOLD THE PATH TO MORE

    VALUABLE AND ENJOYABLE FRONT END TESTING Photo: Istanbul on a rainy day
  4. HOW I MET YOUR COVERAGE THRESHOLD WE ALL WANT IT,

    BUT IT’S SLIGHTLY DIFFERENT ▸ Frontends run on different platforms and environments, and you should be aware of that ▸ In frontends, most bugs come from unpredictable user or unexpected integration behaviour ▸ Frontend tests are usually a nightmare to read ▸ With all the frameworks that we use, they’re also a nightmare to write
  5. HOW I MET YOUR COVERAGE THRESHOLD MEASURE AND TRACK ▸

    Measure, Duh! ▸ Automate, Duh! ▸ Enforce a threshold and keep on increasing it so no code changes would be accepted unless they’re tested
  6. HOW I MET YOUR COVERAGE THRESHOLD TOOLS ARE YOUR FRIENDS

    ▸ Use test coverage tracking tools like codecov, coveralls or codeclimate ▸ Track and use patch coverage ▸ Enforce a patch coverage threshold
  7. HOW I MET YOUR COVERAGE THRESHOLD FOCUS ON THE BIG

    PICTURE ▸ Unit tests are very useful but never enough. Do functional tests instead. They’re more human-readable and cover much more code. Use tools like enzyme and redux-saga-test-plan ▸ Try to run your test suites on different devices and browsers at least once a day. Use services like modern.ie, Sauce Labs, Selenium Grid and AWS Device Farm
  8. HOW I MET YOUR COVERAGE THRESHOLD USE THE TESTING PYRAMID

    ▸ Every time there’s a bug fix, there should be a test case to cover it ▸ Unit and functional tests are easier to write and cheaper to run and maintain
  9. OPTIMISE FOR CHANGE ▸ DRY In tests always repeat yourself.

    Don’t share fixtures between tests ▸ Don’t think of test code like production code. Performance is not a priority in tests ▸ Tests should be optimised for deletion, meaning that they’re independent and self-contained in one place. Don’t split your tests and their data across different files HOW I MET YOUR COVERAGE THRESHOLD
  10. NO CODE IS BETTER THAN NO CODE; UNLESS IT’S TEST

    CODE The golden rule HOW I MET YOUR COVERAGE THRESHOLD NO CODE IS BETTER THAN NO CODE
  11. NO CODE IS BETTER THAN NO CODE; UNLESS IT’S TEST

    CODE The platinum rule HOW I MET YOUR COVERAGE THRESHOLD NO CODE IS BETTER THAN NO CODE; UNLESS IT’S TEST CODE