Table of Contents |
---|
If your testing framework is mocha, SeaLights agent integrates directly with it and reports the test results to the server directly
Info |
---|
See 'Generating an Agent token' for instructions on how to generate a token |
Here is a sample of configuring use instead of the command 'mocha --
...
recursive test
'
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Unix: ./node_modules/.bin/npx slnodejs mocha --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests" --useslnode2 -- --recursive test Windows: call .\node_modules\.bin\npx slnodejs mocha --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests" --useslnode2 -- --recursive test |
Note |
---|
|
Info |
---|
See 'Node.js Command Reference - Running tests using mocha' for full parameter details |
Multiple Reporters Configuration
In case you’re already using a mocha reporter, like allure-mocha
or mochawesome
, it may conflict with the Sealights agent - which adds a reporter of its own (SeaLightsReporter
) which passes the agent the test-events data.
A common solution is to configure the Multi-Reporters plugin:
Create a file
config.json
- with content similar to the one below (that allowssealights
,mocha-allure
, andJUnit
reporters together) for example:Code Block { "reporterEnabled": "slnodejs/tsOutputs/mocha-reporter/index, allure-mocha, mocha-junit-reporter", "seaLightsReporterReporterOptions": {}, "mochaJunitReporterReporterOptions": { "mochaFile": "results/junit-custom.xml" }, "allureMochaReporterOptions": { "resultsDir": "results/allure" } }
When you run slnodejs mocha run it with the following additional parameters:
Code Block npx slnodejs mocha --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId ... -- --reporter-options configFile=config.json