Testing Main Module
You can run code from main module in isolation for testing purposes
While we encourage setting up automated testing using Mocha you can also test your main module methods manually. Typically you will want to test the output of the doLookup
method to make sure it is doing what you expect. To run the doLookup
method in isolation from Polarity you can create a Node.js program that requires
it and then manually call doLookup
.
Start by creating a file called test-runner.js
and placing it in the root directory of your integration.
In the test-runner.js
file require your main-module (if you are following the default guidelines this file will be called integration.js
).
Next, create an options object and set any option values required by your integration. These will be passed to the doLookup
method.
Create an array of entity objects to be passed to your doLookup
method. Note that you only need to provide the properties used by your integration.
Call the doLookup
method of your integration passing in the entities
, options
and a callback method.
Execute your program from the command line on the server using node
. The program will output any errors or the result. In addition, if you have syntax errors in your integration those will be caught and displayed in the console.
Final Code
The following is the full test-runner.js
program which can be adapted to your needs.
In most cases you can rely on the automated error reporting from the Polarity UI. Creating a test-runner
as in the example above is valuable when you are trying to trace through particular sections of code to identify issues.
Last updated