Great tests reflect system behaviour

buildURL(‘/api/fs/facilities’, { state : ‘Nevada’, page : 1 }, null) would return/api/fs/facilities?state=Nevada&page=1
mockAxios.onGet(`/api/fs/facilities`).reply(200, request);
it('should return expected url when passed empty params', () => {   
expect(createUrlWithParams('/url', {})).toEqual('/url?');


Some general guidelines to write great tests:

  1. Write tests that increase your confidence in the code. This confidence reflects when refactoring.
  2. Write tests that document the actual behaviour of the system.
  3. Give descriptive names to the tests. Describe what they are doing.
  4. Tests should give value to the reader and help in understanding the system.
  5. Write tests based on actual requirements.
  6. Write tests for every edge case you can think of.
  7. Tests should keep evolving with code.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store