1
00:00:02,270 --> 00:00:07,310
I kind of answered why we want a test already but I would really want to make this clear again.

2
00:00:07,430 --> 00:00:14,540
Testing so and with that I mean automated tests allows us to automatically test everything and there

3
00:00:14,540 --> 00:00:19,940
is a star behind that because we only test what we define so only the tests we write.

4
00:00:20,000 --> 00:00:23,810
But in theory it allows you to test everything in your application.

5
00:00:23,870 --> 00:00:30,980
After every code adjustment after every code change therefore it's easy to detect breaking changes even

6
00:00:30,980 --> 00:00:35,700
in places you might not have expected to rig upon your latest change.

7
00:00:35,930 --> 00:00:42,430
And with automated tests we ensure that we have predictable clearly defined testing steps.

8
00:00:42,710 --> 00:00:49,070
Our tests obviously always run in the exact same ways and we define all the steps in code and that of

9
00:00:49,070 --> 00:00:53,610
course ensures that we can rely on the scenario always being the same.

10
00:00:53,660 --> 00:00:57,980
If you are manually testing your app you might think you're doing the same thing as you did the last

11
00:00:57,980 --> 00:00:58,550
time.

12
00:00:58,550 --> 00:01:02,600
But in reality you might not be doing that because you forgot a step.

13
00:01:02,690 --> 00:01:04,330
So that is why you should test.

14
00:01:04,370 --> 00:01:12,160
How do you then set up your node project for testing no matter what you're building with node jars.

15
00:01:12,180 --> 00:01:17,310
So no matter if you're building a page where you render the use on the server if you are building a

16
00:01:17,310 --> 00:01:23,600
REST API or if you're building a graph El API you want to run tests automatically.

17
00:01:23,630 --> 00:01:29,350
So you want to run code that tests your code and verdad you typically need a couple of tools.

18
00:01:29,520 --> 00:01:32,560
You need a tool that executes your test code.

19
00:01:32,730 --> 00:01:37,410
Sounds pretty simple but you need that and it should not only execute your code.

20
00:01:37,410 --> 00:01:44,070
It should also give you a nice output that tells you whether your tests all pass or if a test failed.

21
00:01:44,070 --> 00:01:46,570
So that is the first tool we need.

22
00:01:46,650 --> 00:01:52,290
The second tool then is one that does not just run our code but that also allows us to define certain

23
00:01:52,290 --> 00:01:54,240
conditions that have to be met.

24
00:01:54,270 --> 00:02:00,020
So we want to assert certain results we want to find out if certain scenarios.

25
00:02:00,360 --> 00:02:02,550
Well succeeded if test succeeded.

26
00:02:02,550 --> 00:02:06,420
We wanted to find what success means in a certain test.

27
00:02:06,420 --> 00:02:09,540
So we want to validate the test outcome.

28
00:02:09,540 --> 00:02:14,190
Now for running the tests there are different tools for all these steps but for running these tests

29
00:02:14,520 --> 00:02:18,660
one popular framework is mocha and we'll use mocha.

30
00:02:18,660 --> 00:02:26,160
In this module here too and for asserting the results and defining conditions Chai is a popular choice

31
00:02:26,160 --> 00:02:28,970
and we'll use that in this module too.

32
00:02:28,980 --> 00:02:34,740
There are alternatives like just but mocha and Chai are really popular exist for a long time.

33
00:02:34,740 --> 00:02:40,640
There are a lot of tutorials out there for you to dive deeper and therefore I will also use them here.

34
00:02:40,650 --> 00:02:44,400
You're certainly not doing anything wrong when sticking to these tools.

35
00:02:44,400 --> 00:02:50,970
Now as you will see for this module there will also be one ever tool we need when it comes to managing

36
00:02:50,970 --> 00:02:58,380
side effects or working with external dependencies or certain complex scenarios.

37
00:02:58,380 --> 00:03:05,370
There will use sign on which is a tool that allows us to create steps or marks and I will come back

38
00:03:05,370 --> 00:03:07,420
to what that is later.

39
00:03:07,440 --> 00:03:13,470
Now with that all out of the way I'd say let's install our basic testing tools and let's set up our

40
00:03:13,710 --> 00:03:20,100
testing environment and then also write our first test so that we can gradually walk through our node

41
00:03:20,100 --> 00:03:23,220
application and see how we could test it.
