For the complete documentation index, see llms.txt. This page is also available as Markdown.

Other Test Frameworks

Use this page for test frameworks that have no SeaLights integration. There are two ways to get their coverage to SeaLights; prefer the first when the framework can produce it.

The framework can write
Use
Example frameworks

An NYC (Istanbul) JSON report (coverage-final.json)

nycReport + uploadReports

Vitest with @vitest/coverage-istanbul, Jest with --coverageReporters=json, Karma, AVA with nyc

No coverage report

slnodejs run --useinitialcolor true + uploadReports

Jasmine and other CommonJS runners

What you get in both cases: coverage and test results per test stage. Coverage is not split per test, and Test Impact Analysis does not skip tests. For Mocha, Jest, Cypress, Playwright, Cucumber.js and TestCafe, use their integrations instead; see Capturing Tests.

Frameworks that write an NYC report

Follow Unit Tests. For example, with Vitest:

npm install --save-dev @vitest/coverage-istanbul
npx slnodejs openTestStage --tokenFile sltoken.txt --buildSessionIdFile buildSessionId --testStage "Unit Tests"
npx vitest run --coverage.enabled --coverage.provider=istanbul --coverage.reporter=json \
  --reporter=junit --outputFile=reports/junit.xml
npx slnodejs nycReport --tokenFile sltoken.txt --buildSessionIdFile buildSessionId --report coverage/coverage-final.json
npx slnodejs uploadReports --tokenFile sltoken.txt --buildSessionIdFile buildSessionId --file reports/junit.xml
npx slnodejs closeTestStage --tokenFile sltoken.txt --buildSessionIdFile buildSessionId --testStage "Unit Tests"

Frameworks without a coverage report

slnodejs run starts the test runner with the test listener, which collects coverage for the whole run. Run the framework through its JavaScript entry file (not the shell wrapper in node_modules/.bin), after --:

printf '%s' "$SEALIGHTS_AGENT_TOKEN" > sltoken.txt

npx slnodejs openTestStage --tokenFile sltoken.txt --buildSessionIdFile buildSessionId --testStage "Unit Tests"

npx slnodejs run --tokenFile sltoken.txt --buildSessionIdFile buildSessionId \
  --useinitialcolor true -- node_modules/jasmine/bin/jasmine.js

npx slnodejs uploadReports --tokenFile sltoken.txt --buildSessionIdFile buildSessionId --file reports/junit.xml
npx slnodejs closeTestStage --tokenFile sltoken.txt --buildSessionIdFile buildSessionId --testStage "Unit Tests"
  • --useinitialcolor true reports the coverage of the run even though no individual test is identified. The flag takes a value.

  • Upload the results while the test stage is open, and without --testStage: uploadReports --testStage opens and closes a test stage of its own.

  • Configure the framework to write a JUnit XML report (for example jasmine-reporters for Jasmine).

  • The bin field of the framework's package.json names its entry file.

  • If the framework runs the tests in child processes, set SL_enableChildProcessPatcher=true so the test listener also starts in those processes.

  • Add --es6Modules if the code under test is ES modules.

Last updated

Was this helpful?