Mocha Tests framework
Mocha test framework
SeaLights integrates with Mocha through the slnodejs mocha wrapper, which runs SeaLights as a Mocha reporter and reports test results to the server.
Remove any existing --reporter configuration from your Mocha setup — SeaLights runs as a reporter internally and conflicting reporters can break reporting. To keep other reporters, use the multiple reporters setup below.
Basic command
Everything after -- is passed straight to Mocha.
npx slnodejs mocha \
--tokenFile ./sltoken.txt \
--buildSessionIdFile buildSessionId \
--testStage "Unit Tests" \
--useSlNode2 \
-- --recursive test- name: Mocha tests with SeaLights
env:
SL_TOKEN: ${{ secrets.SL_TOKEN }}
run: |
npx slnodejs mocha \
--token "$SL_TOKEN" \
--buildSessionIdFile buildSessionId \
--testStage "Unit Tests" \
--useSlNode2 \
-- --recursive testnpx slnodejs mocha `
--tokenFile .\sltoken.txt `
--buildSessionIdFile buildSessionId `
--testStage "Unit Tests" `
--useSlNode2 `
-- --recursive testReplace --recursive test with your actual Mocha arguments.
Parameters
--tokenFile / --token
SeaLights authentication
--buildSessionIdFile / --buildSessionId
Build session identifier
--testStage
Stage name (e.g. "Unit Tests")
--useSlNode2
Use the v2 Node agent runtime
--
Separates SeaLights options from Mocha arguments
Multiple reporters
To run SeaLights alongside other reporters (e.g. Allure, JUnit), install mocha-multi-reporters and create a config.json:
Then run:
Suite mapping
To map functional tests to Mocha suites instead of individual tests:
Back to → Capturing Tests
Last updated
Was this helpful?

