Learning behavior-driven development with javascript create powerful yet simple-to-code BDD test suites in JavaScript using the most popular tools in the community

This book is ideal for any JavaScript developer who is interested in producing well-tested code. If you have no prior experience with testing, Node.js, or any other tool, do not worry, as they will be explained from scratch.

Detalles Bibliográficos
Otros Autores: Amodeo, Enrique, author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham, England : Packt Publishing Ltd 2015.
Edición:1st edition
Colección:Community experience distilled.
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009628961806719
Tabla de Contenidos:
  • Cover; Copyright; Credits; About the Author; About the Reviewers; www.PacktPub.com; Table of Contents; Preface; Chapter 1: Welcome to BDD; The test-first approach; The test-first cycle; Write a failing test; Make the test pass; Clean the code; Repeat!; Consequences of the test-first cycle; BDD versus TDD; Exploring unit testing; The structure of a test; Test doubles; What is a good test?; Summary; Chapter 2: Automating Tests with Mocha, Chai, and Sinon; Node and NPM as a development platform; Installing Node and NPM; Configuring your project with NPM; Introducing Mocha
  • Useful options in MochaOur first test-first cycle; More expressive assertions with Chai; Working with the ""should"" interface; Red/Green/Refactor; Parameterized tests; Organizing your setup; Defining test scenarios; Test doubles with Sinon; Is it traditional TDD or BDD?; Welcome Sinon!; Integrating Sinon and Chai; Summary; Chapter 3: Writing BDD Features; Introducing myCafé; Writing features; Displaying a customer's order; Tips for writing features; Starting to code the scenarios; Testing asynchronous features; Testing a callback-based API; Testing a promise-based API
  • Interlude: promises 101Mocha and promises; Organizing our test code; The storage object pattern; The example factory pattern; Finishing the scenario; Parameterized scenarios; Finishing our feature; Summary; Chapter 4: CucumberJS and Gherkin; Getting started with Gherkin and CucumberJS; Preparing your project; Writing your first scenario in Gherkin; Executing Gherkin; The World object pattern; Better step handlers; Better reporting; Writing advanced scenarios; Gherkin example tables; Consolidating steps; Advanced setup; Gherkin-driven example factory; Implicit versus explicit setup
  • The Background sectionParameterized scenarios; Finishing the feature; Useful CucumberJS features; Tagging features and scenarios; Hooks; The before hook; The after hook; The around hook; Non-English Gherkin; CucumberJS or Mocha?; Summary; Chapter 5: Testing a REST Web API; The approach; A strategy to test web APIs; Mocha or CucumberJS?; The plan; Testing the GET order feature; Exploring our feature a bit; Starting, stopping, and setting up our server; Testing whether the API responds with 200 Ok; Should we use a realistic order object?; Implementing the test
  • Testing our HAL resource for ordersThe contract with the business layer; Finishing the scenario; Testing slave resources; The order actions; Testing embedded resources; Extracting cross-cutting scenarios; Homework!; Summary; Chapter 6: Testing a UI Using WebDriverJS; Our strategy for UI testing; Choosing the right tests for the UI; The testing architecture; WebDriverJS; Finding and interacting with elements; Complex UI interaction; Injecting scripts; Command control flows; Taking screenshots; Working with several tabs and frames; Testing a rich Internet application; The setup
  • The test HTML page