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.
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.
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.
Before we get started on creating the actual test suite, we'll create a file called
default_options
in thetest/expected/timestamp
directory that contains the expected output of running the task with thedefault_options
target:// Thu, 01 Jan 1970 00:00:00 GMT at London Testing1 2 3
Next, we'll create another file called
custom_options
in the same directory...