# Introduction to Testing

## Introduction to Software Testing

Software testing is a crucial step in the development process that helps identify errors, bugs, and other issues that may affect the quality of the software. It will also help prevent bugs that end up in production code from happening again.

### Methodologies/Types of Tests

There are different types of testing methodologies: Unit Testing, Integration Testing, End-To-End Testing; Acceptance Testing, etc. For this introduction, we will focus on the first two.

#### Unit Testing

Unit tests check the functionality of individual components of an application. A "unit" can be a function, method, or class and is tested in isolation from the rest of the system.

#### Integration Testing

The main goal of integration testing is to identify errors that may arise from the interaction between different components of an application. It involves testing the communication and data exchange between different units and verifying that they work as expected.

Some also consider testing a unit that interacts with the "outside world" (any code that uses AJAX, localStorage, etc.) an integration test.

### Mocking Dependencies

When testing code that uses any kind of dependency such as AJAX, localStorage, or third-party libraries, we can usually safely assume that the dependency is itself well-tested and works correctly.

To isolate the testing to only *our* code we use a technique called mocking where we simulate the behaviour of the dependencies. i.e. Replacing `axios` with a fake ("mock") `axios` that just returns data without making an actual AJAX request.

### Automated Testing Tools

There are various JavaScript testing frameworks like MochaJS, Jasmine, and Jest that help automate the process. For this class we will use [Jest](https://jestjs.io/).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ga0-2.gitbook.io/seifxr10anz-content/week-17/day-1-testing/introduction-to-testing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
