Search⌘ K
AI Features

Writing a Test Without Tools

Explore how to write basic automated tests for a pure email validation function without any testing tools. Learn to verify both valid and invalid cases manually and understand the challenges of scaling tests as complexity grows.

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 ...