mercredi 26 août 2015

Javascript Unit Testing Best Practices

This may be a broad and controversial question... but here we go.

I have never done unit testing on javascript before and id like to know what the best practice is with regards to its deployment.

Unit testing itself is quite straight forward. (its simple to create my own unit test or use existing frameworks such as QUnit.)

My question is around deployment best practice; should unit test code be deployed into production?

For example: i have an object 'person' with the function 'getname()'; then i have the corresponding unit test for this to asset that the name is what i expect.

Quite simple right?... but i have never seen an example of a javascript unit test "in the wild". so when people deploy their work into productions environments:

  • Are they stripping unit test to save on bandwidth?
  • Is there a particular way to handle unit test so that they dont go into production?
  • Is there a tool available that will enable me to unit test locally but strip it for production?

I've never unit tested JS before so im not sure im asking the right question.

Aucun commentaire:

Enregistrer un commentaire