This document outlines the technical procedures for executing local integration tests for the connectToDevice and executeCommand methods using the awaBerry Connect agent. It covers essential preconditions such as awaBerry Connect installation and account setup, environment configuration via a .env file for project credentials and device details, and steps for installing dependencies. Detailed instructions are provided for testing device connectivity, executing arbitrary commands, and managing long-running commands by polling for additional results, ensuring robust validation of the agent's core functionalities.
This guide explains how to run the local method tests for connectToDevice and executeCommand.
Before running the tests, ensure you have the following:
awaBerry Connect agent must be installed on the device you want to connect to. You can download it from download.awaberry.com.<projectKey> and <projectSecret>..env file:.env..env file, replacing the placeholder values with your actual project credentials and device name:
projectKey=your_project_key
projectSecret=your_project_secret
deviceName=your_device_name
npm install
Run the test files from your project's root directory.
This test will attempt to connect to your specified device.
The testConnectToDevice.js file reads connection details from a .env file in the project root and uses them to call the connectToDevice function. Upon successful connection, it updates the .env file with the obtained sessionToken and deviceuuid.
To run this test:
node test/methodtest/testConnectToDevice.js
Expected end of test output:
✅ Method execution was succesful
If the connection test is successful, you can use this command to execute a test command on the connected device.
The testExecuteCommand.js file reads sessionToken and deviceuuid from a .env file, prompts the user for a command via the console, and then calls the executeCommand function. Ensure these values are set, typically after a successful connection test.
To run this test:
node test/methodtest/testExecuteCommand.js
Enter a simple command such as 'date' or 'ls' to test the command execution. On success, the JSON result of the command is printed, ending with:
✅ Method execution was succesful
This test is designed to handle long-running commands by executing a command and then continuously polling for additional results until the command has completed on the terminal or the user explicitly quits. It also provides an option to send a 'stop command' if the initial command is still running when the user requests to quit.
The testGetAdditionalCommandResults.js file requires sessionToken and deviceuuid to be set in your .env file, similar to the command execution test.
To run this test:
node test/methodtest/testGetAdditionalCommandResults.js
During execution, you can press 'q' to quit the polling loop and optionally send a stop command.
projectKey and projectSecret and try again.deviceName in your .env file matches an active device associated with your awaBerry Agentic project.For documentation and questions: