Test Suite
describe is a Cypress method for grouping one or more related tests.
Each describe block represents a test suite. Every time we start writing
a new suite of tests for a functionality, we wrap it in a describe
block.
As we can see describe block takes two arguments: a string for
description of the test suite, and a callback function for wrapping the
actual test.
Test Case
A test case can be written using it block.
A test suite can contain one or more test cases. A test suite can consist
positive and negative test cases related to a functionality. This means that
describe can have one or more it blocks.
Conventions for describe and it block
- The description of a
describe
block must start with uppercase.
- The description of describe block should be short.
- Avoid using “should” or long statements in describe block.
- It can simply be the functionality name.
If we are testing signup functionality, then the describe block
should look like this.
If we are testing login functionality, then the describe block
should look like this.
- The description of a
it
block should always be in lowercase.
- The description of it block can be more specific.
- We can start the description with should or must. However, it's not
mandatory to start with these keywords, just ensure that it is meaningful.
If we are handling customers in a test suite, our test should look like this.
Avoid using vague or generic description like this.