Sharing Behaviour

Learn to use shared behavior to write better tests.

Often, we want to test a number of scenarios, and we end up with duplicate test code. If we have more than a few similar tests, then it will often be clearer to use shared behavior to abstract away that repetition. The simple technique is to wrap our test in a forEach loop. This can let us run the same test for a number of different values.

Get hands-on with 1200+ tech skills courses.