3

So today was my first time combining mocking, depenancy injection and promises. I thought I had a relatively good understanding of everything until I started writing tests - now my head is spinning.

The actual coding has gone really well - implimented the strategy pattern so I can reuse my code whenever I want to make an API call - and everything is nicely decoupled so it should be easy to test. In theory.

If anyone here happens to write tests for a living, I have a new found respect for you today...

Time for a beer 😅

Comments
  • 2
    Try it with TDD if you haven't tried it before, it will definitely change how you write the code in the first place. Still I have to admit that I hate writing tests for promise packed code.
  • 1
    @loebkes I usually TDD my code, but I've been having a bit of trouble since I started working with API's, so I'm trying to pick up some new patterns to help write code that's a bit easier to test.

    I just can't seem to get comfortable with testing JavaScript and the way code is organised in Express after being taught with Sinatra/Rails.

    Yet. I'll get there eventually 😆
  • 0
    @FoolsGambit I have my problems with Javascript TDD too. It's easy at first until you get service calls and promises all over the place. It's easy to get to mocking hell too
Add Comment