Jasmine Best Practices

  1. The file name should be Matching for the top level test suite name.
  2. There should be one top level test suite per file.
  3. Give a meaningful name or title for the test suite.
  4. Either use var or this to define variables that needs to use across tests. var variables should be placed just below the top describe (test suite)
  5. Use setup and teardown methods to perform common variable initializations and functionalities.
  6. A spec (test case) should test only “ONE” expectation.
  7. Group the main test suite with sub test suites to group sections.

Good Test Suite

Following is a structure of a good looking Jasmine test suite.

Learn More

Published by Sinaru Gunawardena

Sinaru is a software developer at work and a painter in free time. He enjoys writing tech notes on his personal website. He currently lives in Dublin, Ireland.

Leave a comment

Your email address will not be published. Required fields are marked *