How should we begin writing tests with documentation?


In defining tests as documentation, how should the it constructs:

it(specifying-sentence, () => {
    /* some test code */

be chosen/defined?


As a first approach, it makes sense to create one it construct for each of the behaviors that we’ve specified before creating the application, as is done in the exercise in question. After we’ve satisfied these basic behaviors, we can gradually add more it constructs as

  • new functionality is carefully specified and added to the application, or
  • as different aspects of the application interact in ways we did not predict.

We must be careful that the tests are explicitly specified so that the documenting sentence, written as specifying-sentence above, is not misleading. This is a natural progression as testing and software development are iterative processes.