Book Image

Grunt Cookbook

By : Jurie-Jan Botha
Book Image

Grunt Cookbook

By: Jurie-Jan Botha

Overview of this book

<p>A web application can quickly turn into a complex orchestration of many smaller components, each one requiring its own bit of maintenance. Grunt allows you to automate all the repetitive tasks required to get everything working together by using JavaScript, the most popular programming language.</p> <p>Grunt Cookbook offers a host of easy-to-follow recipes for automating repetitive tasks in your web application's development, management, and deployment processes. This book will introduce you to methods that can be used to automate basic processes and your favorite tools. By following the recipes, you will soon be comfortable using Grunt to perform a wide array of advanced tasks in a range of different scenarios.</p>
Table of Contents (17 chapters)
Grunt Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Writing tests for a plugin task


The creation of tests forms an essential part of the development of all programming modules, which includes Grunt plugins. Tests provide a way for us to confirm that our tasks work and keep working as expected in a variety of situations.

Getting started

In this recipe, we'll continue to work on the project we created in the Creating a plugin task recipe earlier in this chapter. Be sure to refer to it if you are not yet familiar with its contents.

How to do it...

The following steps take us through creating expected output files and a test suite that checks that the actual output files from the task match them.

  1. Before we get started on creating the actual test suite, we'll create a file called default_options in the test/expected/timestamp directory that contains the expected output of running the task with the default_options target:

    // Thu, 01 Jan 1970 00:00:00 GMT at London
    Testing1 2 3
  2. Next, we'll create another file called custom_options in the same directory...