Testing the action
About this task
Testing the custom action is an optional step to help ensure that the code is working as expected. The testing is done against the mock data in the code.
Procedure
- Suppose that we want to test an action that is created by using the example swagger file __folders__folder_id__items get. Go to the /action/v1/__folders__folder_id__itemsget file. You can see the code structure of the action.
- Test the action by adding the mock_input object under the output object. The mock_input object must have all keys (of the input schema) present in the input object.
- The action is now ready to be tested. Run the
wmio testcommand to test the action. A file that is named auth.con is automatically created at the root level of the current directory. This file contains an object with the authorization details of the action that needs to be tested. The authorization details are used by the CLI while testing the action. Help ensure that the index.json file contains only those actions in the array that you want to test. In the case the index.json file contains an empty array of actions, only then the passed access token is validated. The validation is performed by using the validate function present in the authentication.js file.