Test-Driven JavaScript Development
What This Book is About This book is about programming JavaScript for the real world, using the techniques and workflow suggested by Test-Driven Development. It is about gaining confidence in your code through test coverage, and gaining the ability to fearlessly refactor and organically evolve your code base. It is about writing modular and testable code. It is about writing JavaScript that works in a wide variety of environments and that doesn’t get in your user’s way. How This Book is Organized This book has four parts. They may be read in any order you’re comfortable with. Part II introduces a few utilities that are used throughout the book, but their usage should be clear enough, allowing you to skip that part if you already have a solid understanding of programming JavaScript, including topics such as unobtrusive JavaScript and feature detection. Part I: Test-Driven Development In the first part I’ll introduce you to the concept of automated tests and test-driven development. We’ll start by looking at what a unit test is, what it does, and what it’s good for. Then we’ll build our workflow around them as I introduce the test- driven development process. To round the topic off I’ll show you a few available unit testing frameworks for JavaScript, discuss their pros and cons, and take a closer look at the one we’ll be using the most throughout the book. Part II: JavaScript for Programmers In Part II we’re going to get a deeper look at programming in JavaScript. This part is by no means a complete introduction to the JavaScript language. You should already either have some experience with JavaScript—perhaps by working with libraries like jQuery, Prototype, or the like—or experience from other programming languages. If you’re an experienced programmer with no prior experience with JavaScript, this part should help you understand where JavaScript differs from other languages, especially less dynamic ones, and give you the foundation you’ll need for the real- world scenarios in Part III. If you’re already well-versed in advanced JavaScript concepts such as closures, prototypal inheritance, the dynamic nature of this, and feature detection, you may want to skim this part for a reminder, or you may want to skip directly to Part III. While working through some of JavaScript’s finer points, I’ll use unit tests to show you how the language behaves, and we’ll take the opportunity to let tests drive us through the implementation of some helper utilities, which we’ll use throughout Part III. Part III: Real-World Test-Driven Development in JavaScript In this part we’ll tackle a series of small projects in varying environments. We’ll see how to develop a small general purpose JavaScript API, develop a DOM dependent widget, abstract browser differences, implement a server-side JavaScript application, and more—all using test-driven development. This part focuses on how test-driven development can help in building cleaner API’s, better modularized code and more robust software. Each project introduces new test-related concepts, and shows them in practice by implementing a fully functional, yet limited piece of code. Throughout this part we will, among other things, learn how to test code that depends on browser API’s, timers, event handlers, DOM manipulation, and asynchronous server requests (i.e., “Ajax”). We will also get to practice techniques such as stubbing, refactoring, and using design patterns to solve problems in elegant ways. Throughout each chapter in this part, ideas on how to extend the functionality developed are offered, giving you the ability to practice by improving the code on your own. Extended solutions are available from the book’s website.1 I’ve taken great care throughout these projects to produce runnable code that actually does things. The end result of the five chapters in Part III is a fully func- tional instant messaging chat client and server, written exclusively using test-driven development, in nothing but JavaScript. Part IV: Testing Patterns The final part of the book reviews some of the techniques used throughout Part III from a wider angle. Test doubles, such as mocks and stubs, are investigated in closer detail along with different forms of test verification. Finally, we review some guidelines to help you write good unit tests.
剩余524页未读,继续阅读
- 粉丝: 0
- 资源: 16
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于PLC的升降横移立体停车库的设计,设计一个基于西门子S7-200 PLC控制核心的,三层三列,九个车位的立体停车控制系统 目录\\t3 1 绪 论\\t4 2 设计要求\\t5 3 硬件设
- 基于springboot的物业管理系统源码(java毕业设计完整源码).zip
- 教学实习1.2python教学指导书
- 机械设计遮阳板激光自动打码机sw2016可编辑全套设计资料100%好用.zip
- 基于springboot的物业管理系统的设计与实现源码(java毕业设计完整源码).zip
- 教学实习1.2python教学实习答辩
- [pdf、epub]260道《软件方法》强化自测题业务建模需求分析共216页(202412更新)
- 423大神PHP基于MVC三层图书借阅管理系统毕业课程源码设计
- 双碳目标下综合能源系统低碳运行优化调度Matlab程序 包含光伏、风电、热电联产、燃气锅炉、电锅炉、电储能、碳捕集设备,考虑碳交易 以系统运行成本最小为目标进行调度 没有具体参考文献,这个只是一个授之
- 基于springboot的物流管理系统源码(java毕业设计完整源码).zip
- 中国象棋大师.exe中国象棋大师1.exe
- 基于springboot的物流系统源码(java毕业设计完整源码).zip
- CRUISE纯电动车仿真模型,simulink DLL联合仿真,实现电制动优先能量回收策略 关于模型:策略是用64位软件编译的,如果模型运行不了请将软件切成64位 切位置在启动界面platform
- 基于springboot的特殊儿童家长教育能力提升平台源码(java毕业设计完整源码).zip
- CP210x USB红外配置序号
- 丁丁中国象棋.exe中国象棋大师.exe中国象棋大师1.exe