Cargando…

Jasmine JavaScript testing : leverage the power of unit testing to create bigger and better JavaScript applications /

The book uses a concise, to-the-point approach to help developers understand and use the power of Jasmine to create better and more maintainable codebases. This book is a must-have guide for web developers who are new to the concept of unit testing. It's assumed that you have a basic knowledge...

Descripción completa

Detalles Bibliográficos
Clasificación:Libro Electrónico
Autor principal: Ragonha, Paulo
Formato: Electrónico eBook
Idioma:Inglés
Publicado: Birmingham, England : Packt Publishing, 2013.
Colección:Community experience distilled.
Temas:
Acceso en línea:Texto completo
Tabla de Contenidos:
  • Table of Contents; Jasmine JavaScript Testing; Jasmine JavaScript Testing; 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; 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 and first run; Summary; 2. Your First Spec; The Investment Tracker application.
  • Jasmine basics and thinking in BDDSetup 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 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; Integrate Views with observers; Testing Views with jQuery matchers; The toBe jQuery matcher; The toContainHtml jQuery matcher; The toContain 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; Setting up the Scenario; Installing Node.js; Coding the server; Running the server; Writing the spec.
  • The waitsFor() functionThe runs() function; Summary; 5. Jasmine Spies; The ""bare"" Spy; Spy an object's functions; Testing DOM events; Summary; 6. Light Speed Unit Testing; Jasmine Stubs; Sinon. JS; Installing Sinon. JS; A Fake XMLHttpRequest; A Fake server; Summary; 7. Testing Backbone.js Applications; The Backbone model; Declaring a new model; The model attributes; Default attribute values; Events; Sync and AJAX requests; Testing Backbone collections; Declaring a new collection; Sync and AJAX requests; Testing Backbone Views; Declaring a new View; The el property; Rendering.
  • Updating the View on model changesBinding DOM events; Testing Backbone routers; Defining a new router; Defining routes; Using routers; Routers should only route; Summary; 8. Build Automation; RequireJS; Module definition; Project setup; The new SpecRunner. JS file; The RequireJS configuration; Using non AMD dependencies with Shim; Testing a module; Optimizing for production; Headless testing with PhantomJS; Downloading and installing PhantomJS; Running your tests without opening a browser; Grunt; Installation; Project setup; A RequireJS optimizer task; A Jasmine task.