From the course: JavaScript: Test-Driven Development (ES6)
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Solution: Given criteria, write unit tests - JavaScript Tutorial
From the course: JavaScript: Test-Driven Development (ES6)
Solution: Given criteria, write unit tests
(upbeat music) - [Instructor] Okay, so now let's see what one possible way of solving this challenge might be. And this is just the way that I would do it. If you have something a little different don't worry about it too much. So we've got our files created, and the first thing that I'm going to do is import some of the things that we'll need at the top of our test file. So I'm going to import expect from chai to make our assertions, and then I'm going to import our isAnagram function, import isAnagram from Anagrams. And this of course doesn't exist yet. So now to group our files we're going to have a describe block here. And inside we're going to say, isAnagram basic functionality. And I'm going to put these comments that I typed out in the last video just to give us a guideline of the things that we need to test. So the first test that we're going to write we're going to say it returns true when two known anagrams…
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
-
JavaScript frameworks for unit testing2m 36s
-
Writing and running basic tests2m 8s
-
Testing basic functions5m 23s
-
Testing asynchronous functions3m 33s
-
Modifying existing functionality3m 17s
-
To mock or not to mock?3m 58s
-
Challenge: Given criteria, write unit tests3m 14s
-
Solution: Given criteria, write unit tests10m 29s
-
-
-
-
-
-
-