Package detail

mutation-testing-elements

stryker-mutator709.6kApache-2.03.7.1

A suite of web components for a mutation testing report.

readme

Mutation testing badge Build Status

Mutation testing elements

A suite of elements designed to display a mutation testing report.

overview (light mode) overview (dark mode)
mutant view (light mode) mutant view (dark mode)
test view (light mode) test view (dark mode)

*Note: Please see https://stryker-mutator.io for an introduction to mutation testing.*

Features

The mutation test report supports the following features:

📊 Calculates and displays the mutation score and other metrics
📁 Group results into directories
👓 Show mutants directly in your source code
😎 Code highlighting with Prism
🧙‍ Filter mutants based on the outcome
🌑 Switch between light and dark theme
🔗 Deep linking using anchors (uses fragment, so path will not be contaminated)
💅 A beautifully crafted UI made with tailwind CSS
🎓 Adheres to custom element best practices

Install

Install with npm:

$ npm install mutation-testing-elements

Add to your page:

<script defer src="mutation-test-elements/dist/mutation-test-elements.js"></script>

Or you can use the unpkg as your CDN:

<script defer src="https://www.unpkg.com/mutation-testing-elements"></script>

Usage

Use the mutation-test-report-app element to load the mutation test report.

<mutation-test-report-app src="mutation-report.json" title-postfix="Mutation Test Report"></mutation-test-report-app>

This loads the report from the source (src) and displays it.

Alternatively, you can use property binding directly:

<mutation-test-report-app></mutation-test-report-app>
<script>
  document.getElementsByTagName('mutation-test-report-app').item(0).report = {
    /* ... */
  };
</script>

Add this snippet to change the background color of the whole page when the theme is changed from light to dark:

<script>
  const app = document.getElementsByTagName('mutation-test-report-app').item(0);
  function updateTheme() {
    document.body.style.backgroundColor = app.themeBackgroundColor;
  }
  app.addEventListener('theme-changed', updateTheme);
  updateTheme();
</script>

Feel free to use other ways to bind the report property. For example, you can use <mutation-test-report-app [report]="myReport"></mutation-test-report-app> to bind report to the myReport property in an Angular component.

Mutation testing report schema

The mutation testing report data is expected to be in the format of a the mutation-testing-report-schema. Please view that readme to understand the structure.

For some examples, please see the testResources.

API Reference

src [string]

Default: undefined

Specify a source to load the mutation testing report from. The source is expected to be in JSON format and adhere to the mutation-testing-report-schema.

report [object]

Default: undefined

Specify the mutation testing report directly by binding it to this property. It is expected to adhere to the mutation-testing-report-schema.

titlePostfix [string]

Default: undefined

Specify the postfix to append to the title of the current page. It us reflected as attribute: title-postfix.

theme ['light' | 'dark']

Default: user preference (OS setting)

Specify in which theme the report needs to be shown. Possibilities: 'light' or 'dark'.

themeBackgroundColor [string]

Read-only property with the hex code of the background-color from the current theme.

theme-changed [CustomEvent<{ theme: string, themeBackgroundColor: string }>]

Add an event listener that will raise an event when the theme is changed.

const app = document.querySelector('mutation-test-report-app');
app.addEventListener('theme-changed', (event) => {
  console.log('new theme is', event.detail.theme);
  console.log('backgroundColor hex is', event.detail.themeBackgroundColor);
  // You can also use `app.theme` or `app.themeBackgroundColor` here.
});

Browser compatibility

These elements are built with LitElement, which uses the Web Components set of standards. They are currently supported by all major browsers with the exception of Edge.

For compatibility with older browsers and Edge, load the Web Components polyfills: https://lit-element.polymer-project.org/guide/use#polyfills

Run tests

There are unit tests with Vitest (browser mode) and integration tests using playwright. You can run them with npx nx test or by running npx nx test:unit or npx nx test:integration respectively. There is also a launch configuration so you can debug from vscode.

The integration tests also do screenshot comparisons. Currently, they only run when you're running in a headless browser, because the screenshots differ ever so slightly with the snapshots. You can run npm run test:integration:headless to run locally with screenshot comparison. It will compare and show you a diff file if the diff is deemed to large. Screenshot tests can be updated for your environment with npm run test:integration:update.

Screenshot snapshots are OS dependent, because, again, the screenshots differ ever so slightly on linux vs windows. You can update the screenshot for both linux and windows by running the "Update screenshots" workflow on your branch (with github). Use with caution always double check the diff before updating!

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

3.7.1 (2025-11-24)

Bug Fixes

3.7.0 (2025-11-21)

Bug Fixes

  • elements: respect reduced motion preferences (#3980) (98a1c4c)

Features

  • elements: refresh some icons and colours (#3978) (5cf987e)

3.6.0 (2025-08-13)

Features

  • elements: python code highlighting support (#3860) (88f7292)

3.5.4 (2025-05-27)

Bug Fixes

  • sbt sonatype publishing configuration (4e0a8b5)
  • sbt sonatype publishing configuration (#3780) (b0e18dd)

3.5.4 (2025-05-27)

Bug Fixes

3.5.3 (2025-05-27)

Note: Version bump only for package root

3.5.2 (2025-05-10)

Bug Fixes

3.5.1 (2025-02-10)

Bug Fixes

3.5.0 (2025-01-31)

Bug Fixes

  • deps: update dependency eslint-config-prettier to v10 (#3592) (4be1b70)
  • deps: update dependency typescript-eslint to v8.18.0 (#3562) (c3d2a60)
  • deps: update dependency typescript-eslint to v8.18.1 (#3568) (810e2d2)
  • deps: update dependency typescript-eslint to v8.18.2 (#3573) (b5e350a)
  • deps: update dependency typescript-eslint to v8.19.1 (#3581) (2f15e4a)
  • deps: update dependency typescript-eslint to v8.20.0 (#3591) (df9c4bd)
  • deps: update dependency typescript-eslint to v8.22.0 (#3604) (2708d39)

Features

  • deps: update dependency tailwindcss to v4 (#3605) (b282842)

Reverts

3.4.1 (2024-11-25)

Bug Fixes

  • metrics-scala: compile to Scala 3 LTS version (#3529) (ada0979)

3.4.0 (2024-11-22)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.11.0 (#3474) (c165771)
  • deps: update dependency typescript-eslint to v8.12.2 (#3495) (31aa74e)
  • deps: update dependency typescript-eslint to v8.13.0 (#3504) (622b685)
  • deps: update dependency typescript-eslint to v8.14.0 (#3515) (c50c570)
  • deps: update dependency typescript-eslint to v8.15.0 (#3523) (3702250)
  • deps: update dependency typescript-eslint to v8.5.0 (#3413) (9ed659f)
  • deps: update dependency typescript-eslint to v8.6.0 (#3429) (652d250)
  • deps: update dependency typescript-eslint to v8.7.0 (#3438) (1b69574)
  • deps: update dependency typescript-eslint to v8.8.0 (#3446) (effb179)
  • deps: update dependency typescript-eslint to v8.8.1 (e4cbc5c)
  • elements: consider statusReason for drawer detail (#3508) (3ce9a0e), closes #3481

Features

  • elements: add file picker (#3404) (8310717)
  • elements: animate dot/triangle opening/closing (#3507) (69127f9)
  • elements: listen to prefers-color-scheme event to switch theme (#3518) (3c79cd1)
  • elements: make mutant dots styling more clear (#3475) (10638f4)
  • file-picker: add fuzzy search to file picker (#3517) (577c6c1)

3.3.0 (2024-09-11)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.0.1 (bc40fc5)
  • deps: update dependency typescript-eslint to v8.1.0 (#3363) (e9c2030)
  • deps: update dependency typescript-eslint to v8.2.0 (#3378) (94e4352)
  • deps: update dependency typescript-eslint to v8.3.0 (#3384) (45c20b5)
  • deps: update dependency typescript-eslint to v8.4.0 (#3399) (936f7dc)
  • elements: fix breadcrumb margin for active item (#3369) (35cc30f)
  • elements: improve usage as a library (#3367) (a9d8ff8)

Features

3.2.0 (2024-08-07)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.0.0 (5af7ab6)
  • deps: update dependency typescript-eslint to v8.0.0-alpha.45 (01ddd21)
  • deps: update dependency typescript-eslint to v8.0.0-alpha.46 (afdd494)
  • deps: update dependency typescript-eslint to v8.0.0-alpha.47 (89f553c)
  • deps: update dependency typescript-eslint to v8.0.0-alpha.48 (58aad91)
  • deps: update dependency typescript-eslint to v8.0.0-alpha.49 (4e1718d)

Features

  • report: add Mutation Coverage based on Covered code column (#3310) (d68d9c8)

3.1.1 (2024-07-18)

Bug Fixes

  • deps: update dependency typescript-eslint to v8.0.0-alpha.44 (#3221) (9f0b7cd)
  • detail scroll not being able to scroll all the way down (#3304) (b85a177)

3.1.0 (2024-05-13)

Bug Fixes

Features

  • elements: add highlighting for .sc and .sbt files (#3183) (f131f47)
  • elements: add Rust syntax highlighting & icon (#3181) (795b1d3)

3.0.4 (2024-04-04)

Note: Version bump only for package root

3.0.3 (2024-04-04)

Bug Fixes

Features

Reverts

  • Revert "build(deps-dev): update scala-library from 2.12.18 to 2.13.12 (#3029)" (#3030) (202bfae), closes #3029 #3030

3.0.2 (2023-12-23)

Bug Fixes

  • deps: update dependency eslint-config-prettier to ~9.1.0 (#2885) (c91956f)
  • drawer: preserve whitespace when rendering mutant description and statusReason (#2926) (b23731a)

3.0.1 (2023-11-16)

Bug Fixes

  • exports: add dist/mutation-test-elements.js to package exports (704a5db)

3.0.0 (2023-11-16)

Bug Fixes

  • result-status-bar: only use valid mutants (#2842) (7af8305)

Build System

BREAKING CHANGES

  • mutation-testing-report-schema and mutation-testing-metrics are now ESM
  • report-schema MutantStatus is a union type instead of TS enum

2.0.5 (2023-10-31)

Note: Version bump only for package root

2.0.4 (2023-10-31)

Bug Fixes

  • deps: update dependency eslint-plugin-import to ~2.29.0 (#2812) (e30e293)

Features

  • svelte: support svelte syntax highlighting (#2807) (ec22df7)

Performance Improvements

  • metrics: improve performance for coverage relation (#2778) (c40369d)

2.0.3 (2023-07-27)

Note: Version bump only for package root

2.0.2 (2023-07-27)

Features

  • elements: add progress bar for real-time reporting (#2560) (de0e16c)

2.0.1 (2023-05-11)

Bug Fixes

  • elements-table: transition score colors after update (#2503) (973c5c1)
  • schema: Correctly validate schema version (#2494) (72979e7)

Performance Improvements

  • elements: improve performance of real-time reporting (#2498) (42f8dcf)

2.0.0 (2023-04-29)

Features

BREAKING CHANGES

  • schema Pending is now a valid mutant state. See #2425.

1.7.14 (2023-02-08)

Note: Version bump only for package root

1.7.13 (2023-02-08)

Bug Fixes

  • Hide test files tab if there are no test files (#2139) (14e84d3)

Features

1.7.12 (2022-09-02)

Bug Fixes

  • mutant-id: escape html in mutant attributes (#2070) (d96d53c)

1.7.11 (2022-08-31)

Bug Fixes

  • Set theme color for ignored status mutants (#2043) (1c90c70)

Features

  • improve accessibility of app and metrics-table components (#1839) (60860fd)
  • mutant drawer: hide mutant id (#2065) (0f735fb)
  • sonarqube: jq filter for import to SonarQube (#2044) (36337c0)

1.7.10 (2022-01-28)

Note: Version bump only for package root

1.7.9 (2022-01-28)

Bug Fixes

  • aggregate: also make ids unique (#1673) (3fcbbc6), closes #1672
  • mutation-testing-elements: Don't render statusreason if it's an empty string (#1620) (c5e97e2)

1.7.8 (2021-12-09)

Note: Version bump only for package root

1.7.7 (2021-12-09)

Performance Improvements

  • metrics: use Map for fast testId -> TestModel lookup (dfca0bc)
  • mutation-test-report-app: only recalculate metrics if report changed (42b7bc0)
  • mutation-test-report-app: only render once by setting props in earlier hooks (210da55)

1.7.6 (2021-11-19)

Bug Fixes

Features

  • diff: add new "diff" feature to mutant view (#1515) (c5f0657)

1.7.5 (2021-08-01)

Features

  • metrics: add aggregateResultsByModule function (#1225) (bb690b8)
  • mutant-view: show status reason in drawer (#1290) (0e6750d)

1.7.4 (2021-07-13)

Bug Fixes

  • exports: add default export for the schema (#1255) (d516054)
  • package.json from package report-schema (0233173)

1.7.2 (2021-05-03)

Bug Fixes

  • elements: add check if localStorage is available (#1073) (9e57c0a)
  • sonatype: incorrect project folder for elements and report-schema Sonatype release (#1072) (4b2358d)

1.7.1 (2021-05-02)

Features

  • info: add tooltip information about states (#1069) (af88c1e)
  • test-view: add test view with test details (#1014) (33bb646)

1.7.0 (2021-03-19)

Features

Reverts

  • Revert "test: remove metrics-scala tests" (85b2732)
  • Revert "Use setup-scala" (db9a528)

1.6.2 (2021-02-24)

Features

  • file: add methods to retrieve source content (#928) (0d3d851)

1.6.1 (2021-02-23)

Bug Fixes

  • mutant-model: add missing statusReason field (#916) (80ffbec)

1.6.0 (2021-02-22)

Features

1.5.1 (2020-12-23)

Bug Fixes

  • metrics-scala: publish project in a single go (932d05f)

1.5.0 (2020-12-23)

Bug Fixes

  • build: fix release process (4ef6e18)
  • report-schema: replace no-break space with normal space (#815) (5e7e6bc)
  • schema: correctly use "title" and "description" (#804) (1834510)

Features

  • metrics-scala: add support for test coverage and metadata (#816) (580f34a)
  • metrics-scala: align naming of types with schema (#810) (f47af3e)
  • report-schema: generate TS types from schema (#811) (3aa4a95)
  • schema: add config, test coverage and metadata (#805) (df34b68)

BREAKING CHANGES

  • metrics-scala: MutationTestReport was renamed to MutationTestResult
  • metrics-scala: MutationTestResult was renamed to FileResult

1.4.4 (2020-11-04)

Bug Fixes

  • metrics-scala: drop null-values from circe json (0293141)

1.4.3 (2020-11-04)

Bug Fixes

  • ts: make project root optional in TS api (#721) (c066733)

1.4.2 (2020-11-03)

Bug Fixes

  • metrics-scala: release process if versions in submodules differ (525f791)
  • sonatype: give elements and report-schema their own sonatype version (ec93ce3)

1.4.1 (2020-10-27)

Reverts

  • Revert "Apply formatting for new prettier version" (30ab981)

1.4.0 (2020-08-25)

Bug Fixes

  • elements: fix stryker config in elements (#592) (01d5c9a)
  • sonatype: fix release process for sonatype (a308a85)

Features

  • metrics-scala: add optional description field (#602) (2ef280c)
  • metrics-scala: add support for RuntimeError mutant status (#609) (d4c9ae5)

1.3.1 (2020-03-28)

Features

  • elements: support syntax highlighting for php (#394) (0cc5af4), closes #393
  • sbt: use sbt for npm projects publishing (#356) (6970350)

1.3.0 (2020-02-27)

Bug Fixes

  • metrics-scala: score should be NaN when there are 0 mutants (#303) (b3627e4)
  • font styling being excluded by postcss (#311) (5e53bd1)

Features

  • icons: add icons to a few file types (#173) (a8752b8)
  • ignored status: add MutantStatus Ignored (#239) (68b2302), closes #85
  • line-numbers: add line numbers in code samples (#313) (20b3eab)
  • n/a mutation score: support no mutation score (66a1549)

1.2.3 (2019-12-11)

Note: Version bump only for package root

1.2.2 (2019-12-04)

Bug Fixes

  • metrics: correct lodash import (3c5d6d2)

1.2.1 (2019-11-24)

Features

  • elements: allow override of top offset (#214) (b6c5c36)
  • metrics: make normalizeFileNames public (3017700)

1.2.0 (2019-10-02)

Features

  • add mutation-testing-metrics for Scala (#65) (6e732ad)
  • build: use postcss to optimize css assets (8f24f06)

1.1.1 (2019-07-15)

Bug Fixes

1.1.0 (2019-06-17)

Features

  • color: add new color for state no-coverage (1fec8c4)
  • emoj: add mutant emoijs (419da6d)
  • mutant description: show optional mutant description (#37) (1f10847)

1.0.7 (2019-04-18)

Features

  • TypeScript: publish type information (#32) (6a41f7e)

1.0.6 (2019-04-09)

Features

  • metrics: move metrics to it's own package (#28) (fc66b8b)

1.0.5 (2019-04-05)

Bug Fixes

  • schema: fix resources dir for maven plugin (ea130e9)

1.0.4 (2019-04-05)

Note: Version bump only for package root

1.0.3 (2019-04-05)

Bug Fixes

  • schema: refer to position with name instead of id (6fe7d0e)

Features

  • muted title: create a muted title (ee1fa8e)
  • popup: color the arrow (b13898a)
  • popup: make popup visible at bottom of the screen (#24) (9606f03)
  • popup: vertical align popup text in middle (849a366)
  • sonatype: Add Sonatype release (#21) (f5447d6)
  • table headers: don't overlap breadcrumb (fa9d638)

1.0.2 (2019-03-26)

Features

  • mutant popup: add popup for selected mutant (#17) (0597327)

1.0.1 (2019-03-15)

Bug Fixes

  • dist: restructure dist folder (fdcb363)

1.0.0 (2019-03-13)

Bug Fixes

  • schema: validate position end object (a99be0f)

Features

  • schema: allow additional properties and validate schema version (a405212)