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.
Modifying existing functionality - JavaScript Tutorial
From the course: JavaScript: Test-Driven Development (ES6)
Modifying existing functionality
- We'll we've done the red step with our failing test and the green step by making that test pass. So far we don't have anything to refactor yet, so lets go back to red and write another failing test. This time lets see if our function returns the correct object for a simple word like cat. So lets define another it lock here and we're going to say that our get letter count function should return the correct letter count for a word with only one of each letter. And inside our function here, we're going to define our expected result, which will be an object like this const expected equals C 1 A 1 T 1 and then we'll define our actual result const actual, which will be the return value of our get letter count function. When we call it with the string cat and finally we're going to make the same kind of assertion that we made in our previous test. So expect actual to deep equal expected now lets run our test to make…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
The purpose of unit testing3m 51s
-
(Locked)
JavaScript frameworks for unit testing2m 36s
-
(Locked)
Writing and running basic tests2m 8s
-
(Locked)
Testing basic functions5m 23s
-
(Locked)
Testing asynchronous functions3m 33s
-
(Locked)
Modifying existing functionality3m 17s
-
(Locked)
To mock or not to mock?3m 58s
-
(Locked)
Challenge: Given criteria, write unit tests3m 14s
-
(Locked)
Solution: Given criteria, write unit tests10m 29s
-
-
-
-
-
-
-