Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Current »

If your testing framework is mocha, SeaLights agent integrates directly with it and reports the test results to the server directly

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'

Unix:
npx slnodejs mocha --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests" --useslnode2 -- --recursive test
 
Windows:
call npx slnodejs mocha --tokenfile \path\to\sltoken.txt --buildsessionidfile buildSessionId --teststage "Unit Tests" --useslnode2 -- --recursive test
  • "--recursive test" are sample parameters passed to mocha and should be replaced by your own

  • SeaLights runs as a mocha reporter, you should remove any parameters setting the reporter otherwise they will conflict

  • Note the double dash delimiter (--) between the sealights options and parameters passed to mocha

Multiple Reporters Configuration

In case you’re already using a mocha reporter, like allure 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:

  1. Install https://www.npmjs.com/package/mocha-multi-reporters

  2. Create a file config.json:

    {
        "reporterEnabled": "slnodejs/tsOutputs/mocha-reporter/index, mocha-allure-reporter",
        "SeaLightsReporterReporterOptions": {},
        "mochaAllureReporterOptions": {
            "targetDir": "allure-results"
        },
        "mochaJunitReporterReporterOptions": {}
    }
  3. When you run slnodejs mocha run it with the following additional parameters:

    npx slnodejs mocha --tokenfile /path/to/sltoken.txt --buildsessionidfile buildSessionId ... -- --reporter-options configFile=config.json
  • No labels