> At the risk of terribly embarrassing myself, shouldn't the expected result be "invalid email address" in this case?
Indeed. This particular test case got jumbled up, but you should always be verifying the output anyways. You can ask it to correct itself when this happens, i.e.:
User: That's wrong. The test would return 'Invalid email address' here, not 'example.com'
Llama: Ah, I see! Thank you for correcting me! In that case, here's the modified test case:
test('it should validate email addresses with special characters', () => {
const testVal3 = emailTest('hello@$%^&*()_!');
expect(testVal3).toBe('Invalid email address');
})
Llama: Now, when the `emailTest` function is called with the input 'hello@$%^&\*()_!', it will return 'Invalid email address' instead of 'example.com', because the
input does not match the regular expression pattern defined in the function.
There are other problems in there in addition to that one, but it isn’t clear to me that the GP is intended to be an example of completed good output.
Indeed. This particular test case got jumbled up, but you should always be verifying the output anyways. You can ask it to correct itself when this happens, i.e.: