Sealights Integration

About Sealights Integration

SeaLights is a quality intelligence platform that assesses and quantifies code coverage for individual tests. You can integrate Sealights with Testim, enabling you to create and run tests in Testim while using Sealights to analyze the test coverage. Integration can be done using a CI or CLI.

Prerequisites

Before running a Testim test with Sealights integration, you first need to:

Running a Test with Sealights Integration

The following is a brief explanation of the workflow for running a Testim test with Sealights integration.

  1. Start Listener – notify the SeaLights server that a test stage is starting.
  2. Run Agent – run the Agent on the Sealights app server.
  3. Run Test – run the test in Testim.
  4. Upload Report – send a status report for the test run from Testim to the Sealights server.
  5. End Test – stop all test processes in Sealights.
  6. View Coverage Result – view the coverage results on the Sealights portal.

CI Integration

CI integration is done by adding the Sealights commands to the CI Shell as scripts that run before and after the Testim test run.
The following diagram shows the integration procedure using a CI platform (e.g. Jenkins).

To run Sealights with Testim using a CI:

  1. Start the listener by adding the following command to the pre-test script:
./node_modules/.bin/slnodejs start --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests"
call .\node_modules\.bin\slnodejs start --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests"
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Starting a test stage.
  2. Start running the backend server by adding the following command to the pre-test script:
./node_modules/.bin/slnodejs run --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --workspacepath "." --useinitialcolor true --useslnode2 -- /your/backend/server/command
call .\node_modules\.bin\slnodejs run --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --workspacepath "." --useinitialcolor true --useslnode2 -- \your\backend\server\command
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Running backend server.
  2. Run the test on Testim by adding the following command to the Run Test script:
testim --label "<YOUR LABEL>" --token "<YOUR ACCESS TOKEN>" --project "<YOUR PROJECT ID>" --grid "<YOUR GRID NAME>" --report-file test-results/TESTIM-TESTS-REPORT.XML
  1. Fill in the parameters as described in Testim Command line interface (CLI).
  2. Upload the Testim result files to the Sealights server by adding the following command to the Post-Test script:
./node_modules/.bin/slnodejs uploadReports --TOKENFILE /PATH/TO/SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID --reportFile JUNIT.XML
call .\node_modules\.bin\slnodejs uploadReports --TOKENFILE \PATH\TO\SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID --reportFile JUNIT.XML
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Upload report files.

📘

For Testim integration, specify the path to the Testim report file as designated in your Testim run command: report-file test-results/TESTIM-TESTS-REPORT.XML.

  1. Notify the Sealights server that the test procedure has ended by adding the following command to the post-test script:
./node_modules/.bin/slnodejs end --TOKENFILE /PATH/TO/SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID
call .\node_modules\.bin\slnodejs end --TOKENFILE \PATH\TO\SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Ending a test stage.
  2. After running a Testim test in Sealights, you can view the test coverage results on the Sealights portal.

CLI Integration

CLI integration is done by running the commands for Sealights and Testim in the proper sequence. There are Sealights processes that need to be run before running the test in Testim and additional processes that need to be run after the test.

📘

Alternatively, you can create a JavaScript Testim configuration file and add the Sealights commands to the beforeSuite and afterSuite processes. Then, when you run the config file the processes will automatically run sequentially. Contact your Testim Support Agent to find out more about this method.

The following diagram shows the integration procedure using the CLI.

To run Sealights with Testim using the CLI:

👍

Ensure that you are running the latest version of Testim by running the following install command from time to time: npm install -g @testim/testim-cli.

  1. Start the listener by entering the following command in the CLI:
./node_modules/.bin/slnodejs start --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests"
call .\node_modules\.bin\slnodejs start --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests"
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Starting a test stage.
  2. Start running the backend server by entering the following command in the CLI:
./node_modules/.bin/slnodejs run --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --workspacepath "." --useinitialcolor true --useslnode2 -- /your/backend/server/command
call .\node_modules\.bin\slnodejs run --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --workspacepath "." --useinitialcolor true --useslnode2 -- \your\backend\server\command
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Running backend server.
  2. Run the test on Testim by entering the following command in the CLI :
testim --label "<YOUR LABEL>" --token "<YOUR ACCESS TOKEN>" --project "<YOUR PROJECT ID>" --grid "<YOUR GRID NAME>" --report-file test-results/TESTIM-TESTS-REPORT.XML
  1. Fill in the parameters as described in Testim Command line interface (CLI).
  2. Upload the Testim result files to the Sealights server by entering the following command in the CLI:
./node_modules/.bin/slnodejs uploadReports --TOKENFILE /PATH/TO/SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID --reportFile junit.xml
call .\node_modules\.bin\slnodejs uploadReports --TOKENFILE \PATH\TO\SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID --reportFile junit.xml
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Upload report files.

📘

For Testim integration, specify the path to the Testim report file as designated in your Testim config file: report-file test-results/TESTIM-TESTS-REPORT.XML.

  1. Notify the Sealights server that the test procedure has ended by entering the following command in the CLI.
./node_modules/.bin/slnodejs end --TOKENFILE /PATH/TO/SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID
call .\node_modules\.bin\slnodejs end --TOKENFILE \PATH\TO\SLTOKEN.TXT --BUILDSESSIONIDFILE BUILDSESSIONID
  1. Fill in the parameters as described in SeaLights Node.js agent - Command Reference - Ending a test stage.
  2. After running a Testim test in Sealights, you can view the test coverage results on the Sealights portal.