Skip to content

Commit e4e90be

Browse files
committed
docs: what is testing
1 parent eafb0b1 commit e4e90be

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

lessons/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: default
3+
title: Unit Testing React
4+
---
5+
6+
<ul>
7+
{% for page in site.pages %}
8+
{% if page.title and page.url != "/" %}
9+
<li>
10+
<a href="/unit-testing-react/{{ page.url }}">{{ page.title }}</a>
11+
</li>
12+
{% endif %}
13+
{% endfor %}
14+
</ul>

lessons/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

lessons/what-is-testing.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# What is Testing?
2+
3+
Testing is the process of verifying whether something works as expected.
4+
5+
## Manual testing
6+
7+
1. Run the app.
8+
2. Click on the "Click to Start" button and check if a question appears.
9+
3. Next, type an answer and click the "Submit Answer" button. Verify if you receive feedback about your response.
10+
11+
### What happens when you add more features?
12+
13+
Each time you introduce new features, you need to manually test everything again to ensure it all still works. This can become time-consuming and error-prone, right?
14+
15+
That's where Automated Testing comes in!
16+
17+
## Automated Testing
18+
19+
Automated tests are scripts that run your production code and automatically check if it behaves as expected. If something isn't working correctly, the test will throw an error, making it easier to catch bugs early.
20+
21+
For example, let's look at the file `utils/is-equal.js`. It contains a function that compares two values.
22+
23+
To test this function, you can write a simple test like this:
24+
25+
```js
26+
const result = isEqual(1, 2);
27+
const expected = true;
28+
29+
if (result !== expected) {
30+
throw new Error(`${result} is not equal ${expected}`);
31+
}
32+
```
33+
34+
This way, you can quickly see if the function works as intended without manually testing it each time.

0 commit comments

Comments
 (0)