Обучающие видео » Компьютерные видеоуроки и обучающие интерактивные DVD » Программирование (видеоуроки)
Unit Testing JavaScript (with CoffeeScript)Год выпуска: 2015
Производитель: frontendmasters.com
Сайт производителя:
https://frontendmasters.com/courses/unit-testing-javascript/Автор: Justin Searls
Продолжительность: 4 hours, 45 min
Тип раздаваемого материала: Видеоклипы
Язык: Английский
Описание: We are writing increasingly complex applications in JavaScript both in the Browser and the server-side using Node.JS. With this increased complexity comes a need to understand the nuances of testing. This course covers how to write testable code, types of tests, testing strategies, tactics and tips that will increase your ability to test JavaScript on the client and the server (Node.js). The unit tests are written in CoffeeScript, but the testing strategies you'll learn will be useful in pure JavaScript as well.
Slides (PDF) -
https://frontendmasters.com/assets/resources/searlsmosher/javascript-testing.pdfCode (Github) -
https://github.com/testdouble/real-world-testing/Code + Challenge Videos (Github) -
https://github.com/testdouble/real-world-testing-video[spoiler="Содержание"]
Table of Contents
Introduction
Introduction
00:00:00 - 00:05:50
Introduction
Dave Mosher and Justin Searls the course with a brief summary of their work histories and how the came to work at Test Double.
Background
00:05:51 - 00:12:15
Background
Before getting into the content, Justin explains where to get the course files. He also gives a little background about the syntax used throughout the course. They will be writing most of their unit tests in CoffeeScript. -
http://github.com/testdouble/real-world-testing-videoCoffeeScript Basics
00:12:16 - 00:18:55
CoffeeScript Basics
Since most of the testing code will be written in CoffeeScript, Dave and Justin spend a few minutes explaining the syntax. They talk about why they prefer CoffeeScript over JavaScript for unit testing and compare how tests would look in both languages.
Roman Numeral Calculator
Setup
00:18:56 - 00:26:16
Setup
The first demo will involve building a Roman Numeral calculator and writing tests against its functionality. Before getting into the code, Dave walks through the environment setup and project dependencies. The repo for this course is organized into folders. It also includes videos for each demo.
Test-Driven Development
00:26:17 - 00:36:12
Test-Driven Development
Before writing any application code, Dave begins with the unit tests. Part of test-driven development is writing the specification for what the application should do before implementing the functionality.
Writing and Refactoring Unit Tests
00:36:13 - 00:43:49
Writing and Refactoring Unit Tests
Dave continues writing test cases for the Roman Numeral calculator. As his code begins to grow, he takes a few minutes to refactor it to create a more concise and readable spec.
Refactoring Application Code
00:43:50 - 00:49:04
Refactoring Application Code
Dave finishes the Roman Calculator example by refactoring the application code. He demonstrates how a growing number of test cases can pinpoint areas in the applicant code that need optimization. Because the test are already written, he can monitory them during the optimization process to ensure the code is still functional.
Questions
00:49:05 - 01:01:42
Questions
Dave and Justin take a few minutes to review the Roman Numeral Calculator and answer a number of audience questions about test-driven development.
Node
Testing Pyramid
01:01:43 - 01:09:41
Testing Pyramid
Justin takes over and begins the next section with a explanation of the Testing Pyramid. The Testing Pyramid illustrates the greater need for discovery testing and a smaller need for end-to-end testing.
Discovery Testing
01:09:42 - 01:18:13
Discovery Testing
Justin’s calls his approach to unit testing “discovery testing”. This involves breaking down the feature into smaller pieces and identifying each responsibility. Justin demonstrates his discovery process on his arithmetic problem generator.
Trees
01:18:14 - 01:29:10
Trees
Diagramming the functionality in tree-form will help break down tasks into smaller units. These smaller units, or leaf nodes, are pure functions that can be easily tested. Mocks can be built to supply these leaf nodes with test data.
Integration Tests
01:29:11 - 01:40:52
Integration Tests
Before getting into the unit tests for their arithmetic problem generator, Dave and Justin explain the integration tests that are pre-build for this application. They also talk about a few of the additional libraries they will be using and introduce the concept of helpers.
Other Dependencies
01:40:53 - 01:46:35
Other Dependencies
Dave finishes his summary of the project dependencies by explaining the grunt-jasmine-bundle module configuration. He also introduces the first unit test.
Video 1: First Unit Test
01:46:36 - 01:58:50
Video 1: First Unit Test
Dave and Justin begin walking through the first video which demonstrates the coding of the initial unit tests. Justin also spends a few minutes talking about how he determines where to start with his testing and why he isn’t writing unit tests for the Express application.
First Unit Test, continued
01:58:51 - 02:06:41
First Unit Test, continued
With the initial unit tests written (and failing), Justin and Dave move on to writing the code for the first collaborator and a few mocks for the subsequent collaborators. They also briefly explain the role of a Jasmine Spy.
Video 2: Generating a Problem
02:06:42 - 02:15:01
Video 2: Generating a Problem
Justin and Dave walk through the unit tests for generating a problem. The tests will verify a character is returned for the operator and numbers are generated for the left and right operands.
Video 3: Picking Random Values
02:15:02 - 02:27:33
Video 3: Picking Random Values
The next challenge is to ensure a random problem is generated. Dave and Justin explain one technique for testing randomness. After implementing the unit tests, they add the production code.
Video4: Saving a Problem
02:27:34 - 02:37:22
Video4: Saving a Problem
Now that a random problem is being generated, the problem needs to be saved. The unit tests in this video will verify a problem is stored in memory using it’s ID as the key.
Video 5: Presenting a Problem
02:37:23 - 02:43:38
Video 5: Presenting a Problem
Justin and Dave create a unit test to verify a problem is presented to the user correctly. The production code combines the left and right operands with the operator to create a well-formed problem.
Videos 6 & 7: Finishing the Application
02:43:39 - 02:50:44
Videos 6 & 7: Finishing the Application
The final two videos demonstrate the application in action. Dave and Justin talk through the process of wiring in Express to finalize the production code.
Discovery Testing Wrap-up
02:50:45 - 03:02:06
Discovery Testing Wrap-up
Dave switches to the answers branch in the repository to walk through the completed code and wrap-up the section on Discovery Testing. Both he and Justin field a few audience questions and talk a little more about strategies around code reuse.
Lineman
Lineman Background
03:02:07 - 03:09:12
Lineman Background
Before getting into the next section on Lineman, Justin and Dave spend a few minutes answering audience questions and talking about task automation with the npm run command.
Video 1: Jasmine Fixtures
03:09:13 - 03:21:56
Video 1: Jasmine Fixtures
After a brief explanation of the command line tool, Lineman, Dave and Justin begin walking through the first code video. They are using Jasmine Fixtures to make it easier to inject and test HTML snippets into the DOM. -
http://linemanjs.comJasmine Fixtures, continued
03:21:57 - 03:31:30
Jasmine Fixtures, continued
Dave and Justin next implement the createApplication function that will spin-up the application. They also talk about the test-runner, Test’em, and demonstrate how it can be used to test multiple connected browsers/devices. The video concludes with the first passing test.
SpyOn Function
03:31:31 - 03:37:01
SpyOn Function
As mentioned earlier, Jasmine Spies are able to sub any function and track calls to it and any arguments passed. The spyOn method is used to create a spy. Dave and Justin talk about how spies can be used to monitor the instantiation of template files in client-side applications.
Affix Function
03:37:02 - 03:44:08
Affix Function
The affix function in the Jasmine-Fixture library is passed a selector just like the jQuery $ function. However, instead of finding the selector, affix will create an element based on that selector. This is helpful when unit testing because Jasmine-Fixture will remove anything affixed after each test runs.
Video 2: AJAX Spies
03:44:09 - 03:54:13
Video 2: AJAX Spies
Dave and Justin explain how to write a unit test for a UI element that triggers an AJAX request. This example also demonstrates nested unit tests. A key takeaway is that Given statements will always execute before When and Then statements.
Video 3: Captors
03:54:14 - 04:02:44
Video 3: Captors
A captor will save an argument value passed to a function and allow it to be recalled later. Dave and Justin walk through the code for creating a captor and verifying a test is passing once the production code is written.
Connecting the Applications
04:02:45 - 04:08:06
Connecting the Applications
Dave pulls together the Node application written earlier and the front-end application they just completed to demonstrate the finished product. The front-end application makes API calls to the Node application and displays a problem to the user.
Testium
Testium Introduction
04:08:07 - 04:18:19
Testium Introduction
Testium is an integration test library created by Groupon that hooks into libraries like Mocha to provide a browser sync API. Testium will spin up a browser (either real or headless) and accept commands for test automation. Dave gives a quick demonstration of Testium and walks through the documentation.
Using Testium
04:18:20 - 04:22:32
Using Testium
Dave demonstrates how to use Testium with the problem-generator application. The test navigates to the home page, clicks the new problem button, and verifies a correct result.
Testing Challenges
04:22:33 - 04:34:04
Testing Challenges
Dave and Justin begin answering some final audience questions. While doing so, they explain some challenges they face when testing UI element. Dave shares his experience as it relates to testing single-page applications.
Q&A Part 1
04:34:05 - 04:41:14
Q&A Part 1
Dave and Justin take questions from the audience.
Q&A Part 2
04:41:15 - 04:46:07
Q&A Part 2
Dave and Justin wrap up the course with some final audience questions.
[/spoiler]
Файлы примеров: присутствуют
Формат видео: MP4
Видео: AAC, 48kHz, 201kbps, stereo
Аудио: H264, 1920x1080, 16:9, 25 fps, avg 900 kb/s
[spoiler="Скриншоты"]

[/spoiler]