Skip to content

Instantly share code, notes, and snippets.

@matiu
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiu/cf0a1d65865e544899b6 to your computer and use it in GitHub Desktop.
Save matiu/cf0a1d65865e544899b6 to your computer and use it in GitHub Desktop.
Two JS Testing Tips
  1. Test only one class at time. Use sinon.stub (.returns & .yields) to create on the fly mockups for dependencies.
  2. Test the API Only. Never access class internals for checking / setting values. Use the API, this prevents to brake test in the future. E.g.:
  class.setName('name');
  class.name.should.equal('name'); // Wrong
  clase.getName().should.equal('name'); //Right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment