Testing
Testing (or Unit testing) is the process of writing tests for your application. This means that if you write a part of code, you should also write the counter-testing-part to that. Here is an example – a basic function that takes a temperature in Fahrenheit and returns it in celcius:
const convert = fahrenheit => (
Math.round((fahrenheit - 32) * 5 / 9)
)
And that would be a possible test case (based on the testing library AVA):
import test from 'ava'
test(t => {
t.equal(convert(50), 10)
t.equal(convert(82), 28)
t.equal(convert(0), -18)
})
This snippet tests the previously written function with three different values. If AVA gets the expected results, the test passes. If not the test will fail.
In a large-scale application it can often happen that if one thing gets changed, some other function/feature stops working. At scale, it's nearly impossible to check if everything works as proposed by hand. If a test exists for every aspect of the application, one command is enough to know if the application runs as expected.