Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Teardown #1056

@oldoc63

Description

@oldoc63

So far, we've been writing just one test using a single it() block. However, in most situations, we will need to write many tests for a particular feature that get executed in succession.

Running multiple test can introduce issues if the tests make changes to the testing environment: changes to the environment in one test might affect the next test. Some common changes to an environment include:

  • altering files and directory structure
  • changing read and write permissions on a file
  • editing records in a database

To address this issue, we often add a teardown step to the end of our tests. The teardown phase makes our tests isolated by resetting the environment before the next test runs. This provides two key benefits:

  • Changes of the environment caused by one test do not affect the other tests.
  • Isolated tests can be executed in any order.

Note: In some cases -including the previous exercises- the teardown phase isn't needed because there are no conditions to reset.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions