oldoc63 / learningFS

Web development back and front
0 stars 0 forks source link

describe and it blocks #1048

Open oldoc63 opened 2 years ago

oldoc63 commented 2 years ago

In mocha we group the test using the describe function and define test using the it function. These two functions can be used to make your test suite complete, maintainable, and expressive in the following ways:

oldoc63 commented 2 years ago

If you are testing a Math object with the method .max, you could use the following test code:

oldoc63 commented 2 years ago

Both the describe and it functions accept two parameters: a descriptive string and a callback function. Though the functions are flexible, they are commonly used in the structure above: nest describe blocks to resemble the structure of your implementation code and write individual tests in it blocks. This makes your test suite isolated, maintainable, and expressive.

oldoc63 commented 2 years ago
  1. Write a describe-describe-it block for the function Math.min().
  2. In test/index_test.js, create your first describe block using 'Math' as the descriptive string.
  3. Within the block, create another describe block using '.min' as the descriptive string.
  4. Within the block, create an it block using 'returns the argument with the lowest value' as the descriptive string.