Transcript
00:00 The first thing I need to test this greet function is to know what is the actual greeting it returns. So let's call it with a particular argument using John as a username and store the greeting message in a new variable called "message". Then I will compare this actual message with the one I expect,
00:15 so "Hello John". But here's the thing, I don't really care about the cases when this function works as expected. I want to have this test in place so it lets me know when the function doesn't work as expected. So I'll flip this condition and only trigger it if the actual message doesn't equal "Hello John" and if that happens I will throw an error message basically
00:34 letting me know about this. Let's give this code now a try by running it in the terminal. So npx dsx greets dot yes and you can see that the process exited gracefully because there were no errors thrown during the execution. This means that our test was successful. This is a very minimal
00:51 automated test on its own. So we have our system under test, the greet function, we provide a particular input, the John username, and then we compare the actual greeting message with the expected one and notice how now our intentions actually live in the test, in the code. And if those two are not the same we will throw a meaningful error message letting us know that
01:10 our implementation doesn't really fulfill the intention.