Create a script with TruAPI
This task describes how to create a script with TruAPI.
-
Create a standard npm package.
- Open a command window.
-
Create a folder in your script directory.
-
Type
npm init
.The setup questions are optional.
-
Implement the script.
Write your own .js code or use
truapi-gen
to generate a template.- To create a generic test, type
truapi-gen --template default
-
To create a HTTP script, type
truapi-gen --template base-url --testUrl http://<url>/
Tip: Sample scripts can found in the location:
<installdir>\npm\node_modules\truapi\sample
- To create a generic test, type
-
Add transaction names to the
truapi.json
file.A
truapi.json
configuration file is added to the test folder when you run atruapi-gen
command. To display script transactions on the LoadRunner Cloud > Load test > SLA page, manually enter the transactions names, separated by commas, into the transaction section of the file.Note: To automatically update the truapi.json file with transactions names, type
truapi-cli --updateTran
. -
After you have written the TruAPI script, test it locally to verify that it runs without error.
- Open a cmd window.
-
Set the path to the test folder.
-
Type
truapi-cli
.
-
Generate the TruAPI script package.
- Open a cmd window.
-
Set the path to the test folder.
-
Type
npm pack
.A *.tgz is created. This file can be uploaded to LoadRunner Cloud and added to a test definition.
Next steps: