QA testing is an important part of software development, as it helps you to ensure that your code behaves exactly as you expect it to, especially as you develop larger, more complex projects.
There are a number of useful articles out there which help to explain the concepts to you but, essentially, there are two main methodologies when it comes to QA:
-
Test Driven Development (TDD): A technique whereby test cases are written and run against the currently developed code. The code is rewritten as required until all the tests pass.
TDD focuses on how the functionality is implemented within the code.
-
Behaviour Driven Development (BDD): You first define behaviours which you expect from your code (written in simple English or other language common to your team/stakeholders). Then you can write simple automated scripts which can test for these behaviours. Then you write the underlying code and run the tests, rewriting the code as necessary until the desired behaviours are achieved.
BDD focuses on the behaviour of the application for the end user.
This may not make a lot of sense to you, but that’s fine because this course focuses only on TDD. You don’t need to understand BDD at this point.
Whichever methodology you are using, Mocha and Chai are extremely useful tools which can make your job considerably easier.
In terms of TDD:
Mocha is a feature-rich framework which allows you to build suites of tests to run against your code. You will build these suites within existing JS files. These tests will be run for you by the boilerplate code provided, so for now you don’t need to worry about setting that up yourself.
Chai is a library of assertions, which allow you to test specific features of your code, within the Mocha test suites framework. An assertion is simply a statement which tests if a particular input results in the expected output.
EXAMPLE:
assert.equal(1+1, 2) // test passes
assert.equal(1+2, 2) // test fails
The assertion here simply checks that the first value is equal to the second. In practice, you would be feeding a function and input(s) as the first value and checking that the function returns the expected value. There are all kinds of assertions which you will learn about, but they’re pretty self-explanatory.
There are two types of testing which you will learning about:
-
Unit Testing: This tests that specific functions or parts of your code work as expected.
-
Functional Testing: This tests that your app works as expected from the user’s POV. So you test user inputs against the app and ensure that the behaviour of the app is as expected.
This article explains it with a commonly-used analogy:
The FCC QA course basically just runs through the common assertions and concepts, to give you an idea of how it works. You’ll then need to put it into practice properly, writing tests against your own code for the certification projects.
I hope that helps explain it a little for you!