Neurocat, our AI assistant, wrote isStrongPassword(password) for the sign-up form. The code looks decent, but Byte doesn't take anyone's word for it: "Tests first, release later."
A strong password:
- is at least 8 characters long (exactly 8 is fine);
- has at least one digit;
- has at least one Latin letter;
- has no spaces.
Write the suite testPassword(isStrongPassword): it receives the function under test and declares tests with test(name, fn) and expect(value).toBe(expected) (there are also toEqual (opens in a new tab), toBeTruthy, toBeFalsy and toThrow (opens in a new tab)).
The check runs your suite five times: on the correct function (every test must pass: green) and on four mutants, versions with one bug each (at least one test must fail: red). The correct version is available as isStrongPassword; huntMutants(testPassword, "isStrongPassword") prints a report for every version.