4

I tried to find the differences between describe and context. but I'm confused a little bit. So anyone can clarify the difference and the use cases for each one of them.

Also when i should write nested describe in my test case?

Thanks

1 Answers1

2

If you examine the source code of Quick, there is no difference between them. You can nest describes and context however you please and everything will work fine. These functions are mostly tools for you to structure your code in a way that makes sense. For instance you could end up with something like:

describe: The Authentication API
  context: For a logged out user
    describe: The login flow
      it: Should log in a user when the correct credentials are provided
      it: Should not log in a user when incorrect credentials are provided

There aren't any hard-set rules about when or how to use describe and context or when to nest them and in which order. I would recommend to nest and use them in a way that make your tests as easy to read and understand as possible.

donnywals
  • 7,241
  • 1
  • 19
  • 27