售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Jasmine JavaScript Testing Second Edition
Table of Contents
Jasmine JavaScript Testing Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with Jasmine
JavaScript – the bad parts
Jasmine and behavior-driven development
Downloading Jasmine
Summary
2. Your First Spec
The Investment Tracker application
Jasmine basics and thinking in BDD
Setup and teardown
Nested describes
Setup and teardown
Coding a spec with shared behavior
Understanding matchers
Custom matchers
Built-in matchers
The toEqual built-in matcher
The toBe built-in matcher
The toBeTruthy and toBeFalsy matchers
The toBeUndefined, toBeNull, and toBeNaN built-in matchers
The toBeDefined built-in matcher
The toContain built-in matcher
The toMatch built-in matcher
The toBeLessThan and toBeGreaterThan built-in matchers
The toBeCloseTo built-in matcher
The toThrow built-in matcher
Summary
3. Testing Frontend Code
Thinking in terms of components (Views)
The module pattern
Using HTML fixtures
Basic View coding rules
The View should encapsulate a DOM element
Integrating Views with observers
Testing Views with jQuery matchers
The toBeMatchedBy jQuery matcher
The toContainHtml jQuery matcher
The toContainElement jQuery matcher
The toHaveValue jQuery matcher
The toHaveAttr jQuery matcher
The toBeFocused jQuery matcher
The toBeDisabled jQuery matcher
More matchers
Summary
4. Asynchronous Testing – AJAX
Acceptance criterion
Setting up the scenario
Installing Node.js
Coding the server
Running the server
Writing the spec
Asynchronous setups and teardowns
Asynchronous specs
Timeout
Summary
5. Jasmine Spies
The "bare" spy
Spying on an object's functions
Testing DOM events
Summary
6. Light Speed Unit Testing
Jasmine stubs
Jasmine Ajax
Installing the plugin
A fake XMLHttpRequest
Summary
7. Testing React Applications
Project setup
Our first React component
The Virtual DOM
JSX
Using JSX with Jasmine
Component attributes (props)
Component events
Component state
Component life cycle
Composing components
Summary
8. Build Automation
Module bundler – webpack
Module definition
Webpack project setup
Managing dependencies with NPM
Webpack configuration
The spec runner
Testing a module
Test runner: Karma
Quick feedback loop
Watch and run the tests
Watch and update the browser
Optimizing for production
Static code analysis: JSHint
Continuous integration – Travis-CI
Adding a project to Travis-CI
Project setup
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜