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

Karma Test Framework

Karma runs tests in a browser, so SeaLights captures coverage from Karma's coverage reporter and test results from its JUnit reporter. You configure Karma to emit both reports, then drive the standard test-stage lifecycle (start → run → nycReportuploadReportsend).

Karma configuration

Add the JUnit and coverage reporters to karma.conf.js. This requires the karma-junit-reporter and karma-coverage npm packages.

// karma.conf.js
module.exports = function (config) {
  config.set({
    reporters: ['progress', 'junit', 'coverage'],

    junitReporter: {
      outputDir: 'karma-reports',
      outputFile: 'junit.xml',
    },

    coverageReporter: {
      dir: 'karma-reports',
      reporters: [
        { type: 'json', subdir: '.', file: 'coverage-final.json' },
      ],
    },
  });
};

Lifecycle commands

Unit vs. functional: the flow above captures unit coverage from Karma's coverage report. For functional tests, instrument the application first (see Frontend Instrumentation) and drive it with a Lab ID — footprints come from the running app rather than nycReport.

--projectRoot for nycReport: if SeaLights fails to match coverage to source files (common in CI/Docker environments where workspace paths differ from build paths), add --projectRoot <path> to the nycReport call. See Unit Tests → Parameters for details.


Back to → Capturing Tests

Last updated

Was this helpful?