At the beginning, we'll discuss different testing philosophies and go over some testing basics. After establishing a motivation for and philosophy of testing, we're going to dive right into how we express our tests in Jasmine's BDD syntax. We'll also hone in on how to deal with the DOM and AJAX in our tests.
About The Author
Jonathan Freeman is a jazz saxophone player and home cook, and loves to solve problems with code. He wrote his first production application 12 years ago and has been working with BackboneJs in production for the past 3 years. From writing articles for InfoWorld to presenting at conferences and user groups, he loves to teach and jumps at the opportunity to facilitate and observe learning. He's currently interested in complex event processing with rules engines, constraint-based optimization problems, and the fast-moving DevOps ecosystem. He gets to play with all of these technologies and more while at his day job at Spantree Technology Group, a Chicago-based consulting firm. You can find him on twitter at @freethejazz.
The viewer may not know what's in store for them in this course yet. We'll tell you what the scope of the course is, what the goals are, and how we'll go about it.
Testing adds overhead and time to a development process. We want to explain the benefits of testing and describe unit testing and functional testing.
Describe the nuances between TDD and BDD. Prevent confusion of these very similar concepts.
Many tools help in automated testing and it's hard to decide where to start. We'll narrow down the list and describe the necessary programs.
You may not have experience with Jasmine, and may not even have it on your computer. We'll download the library and go through an overview of the directory structure.
Jasmine provides a set of global functions, which we'll introduce and discuss here.
Viewers will get their hands dirty by writing a test using Jasmine style syntax.
We want to add a new feature to our function. The viewer is going to add it on their own in this challenge.
Our section will rely on an understanding of what the recipe model should do. We'll introduce that understanding here.
We need to make sure we start our model testing on the right foot. This video will ensure its existence and that the defaults are configured properly.
We want to be able to check quickly for dietary restrictions. We'll test and implement those methods here.
Some of the setup code is redundant and provides more information than needed. Fixtures will help us cut down on that verbosity and make tests easier to grok.
A fixture is a new concept, and it can be very useful. This hands-on challenge will encourage you to practice using them.
Running automated tests manually is tedious and repetitive. Karma can serve as the automation we need.
We don't yet have the tool to run our tests. We'll install Karma.
We've configured Karma but haven't used it to run any tests yet, which we'll do in this video.
Our code has been fairly disorganized and is arranged in a way that requires us to use Jasmine. We'll refactor and run our tests with Karma.
We don't have a way to store recipes together. We'll create a recipe collection.
We want to be able to see a history of variations in a recipe. The user will write the test and method on their own.
Certain parts of our app depend on AJAX, which can be problematic in a testing environment. The solution is to use SinonJs to intercept AJAX requests and fake responses.
One-off server mocks clutter our code and hamper reusability. Storing our server responses in a single file will encourage cleanliness and maintainability.
Testing views presents a new set of challenges related to dependence on the DOM. We'll start writing tests and run into these issues.
The unique requirements of testing views merit the use of a new library. jasmine-jquery will help us test views in a more efficient and straightforward way.
We need to ensure that our view is rendering properly. With our tools used to effectively test the DOM in place, we're ready to go.
Our recipe app depends on the ability to add notes to a recipe variation. We'll add this functionality, testing with jasmine-jquery.
We can render existing recipes, but we have no way of adding new recipes. In this video, you'll be challenged to write the add recipe view.
Routers are often left to functional testing, but it can be worth unit testing them. We'll discuss when and where to unit test routers.
We need to verify that our route handlers are getting called with the right parameters. We'll discuss spies, which help us track and test calls to functions.
Our first route will be accessing a recipe by ID. In this video, we'll test drive the addition of this route.
In this video, I'll challenge the viewer to use spies on their own by test driving a route on their own.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.