Password Validation with TypeScript and TDD
I decided to share a password validation code from a personal project, using RegExp. The password was tested using Jest so feel free to have a look.
I am using TypeScript let’s create a passwordValidation.ts file.
Then I built separately the requirements of a strong password and passed them down on my function as you can see below.
Now from the testing side I used Jest, if you don’t have it installed please do install the package.
Then create a passwordValidation.test.ts file for your tests.
Now what I did below is to test those scenarios as a true or false assertion.
I created multiple scenarios, there is no limit here :) you can add as many more as you want!!
See you soon!