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

JS Software testing for beginners

JS Software testing for beginners

Lucas Santos

December 05, 2022
Tweet

More Decks by Lucas Santos

Other Decks in Programming

Transcript

  1. Software testing with
    JavaScript_
    a quick guide

    View Slide

  2. who am I_
    {twitter, youtube, linkedin…}.lsantos.dev
    software engineer_
    [email protected]

    View Slide

  3. software testing

    View Slide

  4. software tests are
    untested software that
    tests your software

    View Slide

  5. why?

    View Slide

  6. why automated testing?
    ➔ Improves software quality
    ➔ Prevent errors before they're published
    ➔ Builds trust in the codebase
    ◆ Changes can be published faster

    View Slide

  7. tests should be
    ➔ Deterministic
    ➔ Self-contained
    ➔ Predictable
    ➔ Small

    View Slide

  8. What to test?

    View Slide

  9. Functionality

    View Slide

  10. What not to test?

    View Slide

  11. Implementation

    View Slide

  12. let's hack!

    View Slide

  13. test runners_
    giving us an edge on tests

    View Slide

  14. let's hack!

    View Slide

  15. test doubles_

    View Slide

  16. Types of doubles
    ➔ Spies
    ◆ Adds instrumentation to a function/object
    ◆ Actually calls the function but gathers metadata
    ➔ Stubs
    ◆ Replaces a function for a fake implementation
    ◆ Adds instrumentation
    ◆ Returns a fixed value
    ➔ Mocks
    ◆ "Smarter" stubs
    ◆ Have predefined expectations on interactions
    ◆ Focused on the interaction, not on behaviour

    View Slide

  17. let's hack!

    View Slide

  18. TDD
    Test Driven Development

    View Slide

  19. View Slide

  20. thank you_
    lsantos.dev

    View Slide