Writing a Test Without Tools
Write two automated tests without any tools to learn how difficult the practice can be. This will enable you to understand the benefits of these tools in the future.
We'll cover the following...
The function we want to test
Here is the function we want to test:
function isEmail(email) {
const regex = new RegExp(/^[^@\s]+@[^@\s.]+\.[^@.\s]+$/);
return regex.test(email);
}
The function validates whether an email address is formatted correctly. The function has no dependencies and doesn’t mutate the email
parameter passed into it, which means it is a pure function. Pure functions are simple to test because all their logic is isolated.
We want to write the ...
Access this course and 1400+ top-rated courses and projects.