Agent File
Our Node.js agents (slnodejs
) are published in the npm registry. You download it and all its dependencies using the npm
repository commands.
Downloading latest version
npm i slnodejs
Downloading the recommended version by Sealights (Best Practice)
For Customers that need to set a specific recommended agent version other than the default latest, the API will provide the recommended agent version that has been set on the dedicated settings page from the dashboard.
In the following examples, replace $DOMAIN
with your domain and $SL_TOKEN
with your SeaLights agent token
Linux | # Fetch Agent version defined in Sealights dashboard settings $SLVERSION=$(curl -X GET "https://$DOMAIN.sealights.co/api/v2/agents/slnodejs/recommended" -H "accept: application/json" -H "Authorization: Bearer $SL_TOKEN" -L) # Install Sealights Agent (Recommended version) npm i slnodejs@$SLVERSION |
PowerShell | # Fetch Agent version defined in Sealights dashboard settings $SLVERSION = Invoke-RestMethod -Uri "https://$DOMAIN.sealights.co/api/v2/agents/slnodejs/recommended" -Headers @{ "accept" = "application/json", "Authorization" = "Bearer $SL_TOKEN"} # Install Sealights Agent (Recommended version) npm i "slnodejs@$SLVERSION" |
GitLab YML | before_script: - apt-get -qq update && apt-get install -y jq script: - | SLVERSION=$(curl -X GET "https://$DOMAIN.sealights.co/api/v2/agents/slnodejs/recommended" -H "accept: application/json" -H "Authorization: Bearer $SL_TOKEN" -L | jq -r .agent.version ) npm install slnodejs@$SLVERSION |
Configure a session and create session ID
./node_modules/.bin/slnodejs config {--token <token> | --tokenfile <file>} --appname <appname> --branch <branch> --build <build> [--buildsessionid <buildsessionid>] [--proxy <proxy>] [--failbuild {true|false}]
Parameter | Description |
---|---|
| Access token generated from the Sealights server |
| Path to file containing access token generated from the SeaLights server |
| Name of the application |
| The source branch of the application |
| The build label of the current build |
| (Optional) A user provided session ID |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: |
Scanning a build
./node_modules/.bin/slnodejs build {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} --workspacepath <workspacepath> --scm {git|none} [--projectRoot <folder>] [--excludedpaths <excludedpaths>] [--uniqueModuleId <id>] [--es-modules] [--jobName <jobName>] [--logsUrl <logsUrl>] [--dependenciesFile <dependenciesFile>] [--instrumentForBrowsers --outputpath <folder> [--downloadAgent {true|false}] [--instrumentationOnly] [--labid <labid>]] [--proxy <proxy>] [--failbuild {true|false}] [--scmBaseUrl --scmProvider {github|gitlab|bitbucket} --scmVersion] [--es6Modules] [--babylonPlugins decorators-legacy|jsx]
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Path to the source workspace |
| Comma-separated list of files to exclude from scan Supports wildcards (* = any string, ? = any character). For example: |
| Path to the root of the project. Usually where the src folder resides |
| Unique name when providing more than one build scan per build |
| Indicates that you use es6 modules |
| Name of Jenkins job |
| Path to Jenkins log folder |
| Source control used. Current options are: |
| A path to a JSON file that is in the following format: |
| Instrument the JS files for providing browser front-end coverage information. Must be used with the |
| Set this value to ' |
| Only instrument the javascript files, without sending the build information to the SeaLights server |
| Folder to generate the instrumented JS files in when using the |
| Unique ID for a set of test labs in case multiple labs are running simultaneously or for an integration build. |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: |
| The provider name of your Source Control Management (SCM) tool. |
| The URL to the repository which contains the code. If not provided, the URL of the remote GIT origin will be used Example: |
| The version of your Source Control Management (SCM) tool. If not provided, Cloud version is assumed |
| Values:
|
Ending a multi module build
./node_modules/.bin/slnodejs buildend {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} [--proxy <proxy>] [--failbuild {true|false}] [--skipUpgrade {true|false}] --ok | --failed
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: |
| Should not try to upgrade agent (Default: |
| build finished successfully |
| build not finished successfully |
Updating/Deleting a component from an Integration build
./node_modules/.bin/slnodejs {componentUpdate | componentDelete} {-token <arg> | -tokenfile <arg>} {-buildsessionid <arg> | -buildsessionidfile <arg>} [--proxy <proxy>] {-componentIds <arg> | -componentFile <file>}
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| One or several build session ID's (comma separated) of the component(s) to be updated or deleted |
| A path to a JSON file that is in the following format: |
| Address of proxy to run connection through |
Test Listener
Starting a test stage
./node_modules/.bin/slnodejs start {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} --teststage <teststage> [--labid <labid>] [--proxy <proxy>] [--failbuild {true|false}]
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Name of the test stage |
| Unique ID for a set of test labs in case multiple labs are running simultaneously |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: false) |
Upload report files
Report files must be junit style xml reports
./node_modules/.bin/slnodejs uploadReports {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} {--reportFile <reportFile> | --reportFilesFolder <reportFilesFolder>} [--labid <labid>] [--source <source>] [--type <type>] [--proxy <proxy>] [--failbuild {true|false}]
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Path to report file (multiple entries can be provided) |
| Path to folder containing report files (multiple entries can be provided) Note: all files in the folder will be uploaded |
| Unique ID for a set of test labs in case multiple labs are running simultaneously |
| The reports provider. Default: |
| Values:
|
| Name of testing framework type |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: |
Optional override parameters:
Parameter | Description |
---|---|
| Name of the application |
| The source branch of the application |
| The build label of the current build |
Upload Coverage files
Coverage file must be in JSON format, created by the Istanbul framework
./node_modules/.bin/slnodejs nycReport {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} {--report <reportFile> | --projectRoot <project root dir>} [--labid <labid>] [--proxy <proxy>]
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Path to coverage-final.json |
| Path to the root of the project. Usually where the src folder resides |
| Unique ID for a set of test labs in case multiple labs are running simultaneously |
| Address of proxy to run connection through |
Ending a test stage
./node_modules/.bin/slnodejs end {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} [--labid <labid>] [--proxy <proxy>] [--failbuild {true|false}]
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Unique ID for a set of test labs in case multiple labs are running simultaneously |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: false) |
Running Tests using Mocha
./node_modules/.bin/slnodejs mocha {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} --teststage <teststage> [--labid <labid>] [--proxy <proxy>] [--failbuild {true|false}] -- args...
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Name of the test stage |
| Unique ID for a set of test labs in case multiple labs are running simultaneously |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: false) |
| Extra arguments for running mocha framework tests |
Running Tests using jasmine-node
./node_modules/.bin/slnodejs jasmine {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} --teststage <teststage> [--labid <labid>] [--proxy <proxy>] [--failbuild {true|false}] args...
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Name of the test stage |
| Unique ID for a set of test labs in case multiple labs are running simultaneously |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: false) |
| Extra arguments for running mocha framework tests |
Running backend server
./node_modules/.bin/slnodejs run {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} [--workspacepath <path>] [--useinitialcolor {true|false}] [--teststage <teststage>] [--labid <labid>] [--proxy <proxy>] [--failbuild {true|false}] args...
Parameter | Description |
---|---|
| Access token generated from the SeaLights server |
| Path to file containing access token generated from the SeaLights server |
| Session ID of configuration created |
| Path to file containing the Session ID of configuration created |
| Path to the source workspace |
| When reporting tests manually this should be set to false (Default: false) |
| Name of the test stage |
| Unique ID for a set of test labs in case multiple labs are running simultaneously |
| Address of proxy to run connection through |
| Exit with an error code if an error is encountered (Default: false) |
| Extra arguments for running mocha framework tests |
Logging
To enable logs, you can set the NODE_DEBUG
environment variable to a value defining the output per the table below:
export NODE_DEBUG=sl
Value | Description |
---|---|
| Display log output to the console |
| Export the log information to a log file named ' |
Furthermore, you can set the logging level by using the SL_LOG_LEVEL
environment variable with one of the following options: info
(default) or debug
.
export NODE_DEBUG=sl export SL_LOG_LEVEL=debug
To disable logs, unset the NODE_DEBUG
variable.
export NODE_DEBUG=
The above examples are for Linux shells; for Windows CMD prompt, use the set
command.