Reputation: 39018
TypeError: (0 , _validators.validateEmail)(...).toBe is not a function
Is the error
Here is my test
// Utils
import { validateEmail, validatePassord } from './validators';
describe('validating email addresses', () => {
it('should return true with a valid email', () => {
expect(validateEmail('[email protected]').toBe(true));
});
it('should return false with an invalid email', () => {
expect(validateEmail('badEmail').toBe(false));
});
});
The utility it's testing
export const validateEmail = email => /@google.com\s*$/.test(email);
export const validatePassord = (password) => {
const hasSpecial = /[!]+/.test(password);
const hasAlpha = /[a-zA-Z]+/.test(password);
const hasUppercase = /(?=.*[A-Z])+/.test(password);
const hasNumber = /[0-9]+/.test(password);
const hasMinChars = password.length >= 8;
return hasSpecial && hasAlpha && hasUppercase && hasNumber && hasMinChars;
};
They are in the same directory. Error output:
Upvotes: 3
Views: 1047
Reputation: 474
Try moving your parens around to something like...
expect(validateEmail('[email protected]')).toBe(true);
or something like this for the second test
expect(validateEmail('badEmail')).toBe(false);
Upvotes: 1