From the course: JavaScript: Test-Driven Development (ES6)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Testing basic functions

Testing basic functions - JavaScript Tutorial

From the course: JavaScript: Test-Driven Development (ES6)

Start my 1-month free trial

Testing basic functions

- [Instructor] Okay and that's all the set up we need for now. So now that we've got everything set up, let's talk about what we're going to be coding here. To get a better sense of how the tdd process works, we're going to code a simple example function. And this function is going to take a string as an argument and return an object that contains a count of all the letters in that string. So for example if we pass at the string cat, it'll return an object that looks like this, c:1, a:1, t:1 because the string cat has one c, one a and one t in it. And likewise if we pass at the string better, B-E-T-T-E-R, it'll return an object that looks like this, b:1, e:2 'cause there's two e's, t:2 'cause there's two t's, and r:1, and so on. Now as a matter of fact these two examples I just gave you would make great test cases to test our function with. So let's see how to do that. Let's open up our letter-count.test file and write…

Contents