The first thing we added was eslint.
You can use eslint with its default settings or you can create a
Now that we have eslint, we can update the package.json file with a test to run it.
Jasper Report Test
Now that the setup is complete, we can start writing tests.
Our tests rely on information that might change in the future. So we are going to create a config.js file.
Add a file named "report-runs.js" into the support directory.
Here are the contents of the file.
All of our tests will use this module to verify that the report runs without parameters.
The request module will make our call to the Jasper REST service. The promise module
will help us handle the asynchronous function that our tests will use.
We create a promise that will be fulfilled when the report is run. The caller might get back
true if it ran without error or the error message if it failed. We will set a timeout value
so that our promise call does not run forever.
Now that we have the module that will run the report, we can write a test for the report.
Add a file to run all of the reports into the test folder.
Running the Test
We can update the package.json file with the script to run the tests.
I will bail out of testing if one report fails. I set a 1 minute timeout for running
the tests and a 30 second slow warning in mocha. You can run the tests with "npm start".