Gathering coverage and test information using the SeaLights Node.jsTest Listener is done in a few steps, we recommend to use the Lab ID for this. If your component does not yet support the Lab ID option, use the Build Session .
There are 4 basic steps to gathering coverage and test information using the SeaLights Node.js Agent (slnodejs
).
Start the test stage with slnodejs start ...
Run the Tests
Upload Test Reports
End the test stage with slnodejs end...
For all of the commands on this page, either the Lab ID OR the Build Session ID must be passed as a parameter. For each step, there is one example demonstrating use of the Lab ID and one example demonstrating the use of the Build Session ID.
With the exception of Unit Tests, we recommend using the Lab ID to connect between the test listener and the test runner
...
Info |
---|
See 'Generating an Agent token' for instructions on how to generate a token |
Starting the Test
...
Stage
First the SeaLights server needs to be notified that a test stage is starting.
Code Block |
---|
language | bash | theme | Eclipse |
---|
title | Sample command |
---|
|
Unix:
./node_modules/.bin/npx slnodejs start --tokenfile /path/to/sltoken.txt --labid "<Lab ID>" --teststage "Unit Tests"
Windows:
call .\node_modules\.bin\npx slnodejs start --tokenfile \path\to\sltoken.txt --labid "<Lab ID>" --teststage "Unit Tests" |
Expand |
---|
title | Using Build Session ID |
---|
|
|
...
...
...
npx slnodejs start --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests"
Windows:
call |
|
...
npx slnodejs start --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests" |
|
Running your tests
...
Functional Tests
Before running your functional tests you need to set up the backend server to receive the test footprints. See 'Using Node.js Agents - Running backend server using SeaLights agent'
Once set up you now run your tests normally while generating one or more JUnit xml XML result files to be reported to the SeaLights server.
...
Unit Tests
As the unit tests Unit Tests are not run against a backend server, you need to run the actual tests using the Sealights Node.js Agent while generating one or more JUnit xml XML result files to be reported to the SeaLights server.
The command is the same as you would use on the backend server. See 'Using Node.js Agents - Running backend server using SeaLights agent'
Upload report files
Once done running the tests you upload the report files to the SeaLights server. Note that both Junit and Coverage reports must be uploaded for SeaLights to reflect data for your Unit Tests.
For clarification, see: https://sealights.atlassian.net/wiki/x/DYC28w
Upload report files
Test Case JUnit Report
The slnodejs uploadReports
command can be used to upload the junit.xml file
Code Block |
---|
language | bash |
---|
theme | Eclipse |
---|
title | Sample command for a single file |
|
Unix:
./node_modules/.bin/
npx slnodejs uploadReports --tokenfile /path/to/sltoken.txt --labid "<Lab ID>" --reportFile "/path/to/junit_report.xml"
Windows:
call .\node_modules\.bin\npx slnodejs uploadReports --tokenfile \path\to\sltoken.txt --labid "<Lab ID>" --reportFile "\path\to\junit_report.xml" |
Expand |
---|
title | Using Build Session ID |
---|
|
|
...
...
npx slnodejs uploadReports --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --reportFile "/path/to/junit_report.xml"
Windows:
call |
|
...
npx slnodejs uploadReports --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --reportFile "\path\to\junit_report.xml" |
|
See 'Using Node.js Agents - Uploading multiple files' for information on how to upload multiple files
Info |
---|
See 'Node.js Command Reference - Upload report files' for full parameter details |
Info |
---|
See 'Using Node.js Agents - Uploading multiple files' for information on how to upload multiple files |
Coverage (nyc) Report
The slnodejs uploadReports
command can be used to upload the coverage file generated by nyc
Code Block |
---|
|
Unix:
npx slnodejs nycReport --token $SL_TOKEN --labid $LABID --report "path/to/coverage/coverage-final.json"
Windows:
call npx slnodejs nycReport --token $SL_TOKEN --labid $LABID --report "\path\to\coverage\coverage-final.json" |
Expand |
---|
title | Using Build Session ID |
---|
|
Code Block |
---|
| Unix:
npx slnodejs nycReport --token $SL_TOKEN --buildsessionid $BUILDSESSIONID --report "path/to/coverage/coverage-final.json"
Windows:
call npx slnodejs nycReport --token $SL_TOKEN --buildsessionid $BUILDSESSIONID --report "\path\to\coverage\coverage-final.json" |
|
Ending the Test Stage
Finally notify the server that a test stage has ended.
Code Block |
---|
language | bash | theme | Eclipse |
---|
title | Sample command |
---|
|
Unix:
./node_modules/.bin/npx slnodejs end --tokenfile /path/to/sltoken.txt --labid "<Lab ID>"
Windows:
call .\node_modules\.bin\ npx slnodejs end --tokenfile \path\to\sltoken.txt --labid "<Lab ID>" |
Expand |
---|
title | Using Build Session ID |
---|
|
|
...
...
...
npx slnodejs end --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId
Windows:
call |
|
...
npx slnodejs end --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId |
|