Registry / testing / cypress-json-results

cypress-json-results

JSON →
library1.5.0jsnpmunverified

This plugin for Cypress tests automatically saves test execution results into a JSON file, or formats them for GitHub Actions summaries or Markdown tables. Its current stable version is 1.5.0, with minor feature releases occurring somewhat frequently, as seen by the rapid succession of v1.3.0, v1.4.0, and v1.5.0 in May 2023, indicating active maintenance. Key differentiators include its simplicity in generating a structured JSON output of test statuses, its ability to automatically update Markdown tables within a project with aggregated test counts, and its direct integration with GitHub Actions to provide summary reporting, which is highly beneficial for CI/CD pipelines to quickly grasp test outcomes without needing to download artifacts. Unlike some more comprehensive test reporting solutions, `cypress-json-results` focuses specifically on machine-readable JSON and concise formatted summaries rather than rich, interactive HTML reports, making it ideal for programmatic consumption or quick glance overviews.

npm install cypress-json-results
INSTALL
IMPORT
SIG · CYPRESS-JSON-RESUL
C
cypress-json-results
testingjavascriptv1.5.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin initialization
require('cypress-json-results')({ on, filename: 'results.json' })
import { initialize } from 'cypress-json-results'
This package is a Cypress plugin initialized directly within 'cypress/plugins/index.js' (or equivalent configuration file) using a CommonJS 'require' call and immediate invocation. It does not export named symbols for ES module 'import' statements.

Demonstrates how to register the `cypress-json-results` plugin in `cypress/plugins/index.js` to save test results to a JSON file.

// cypress/plugins/index.js module.exports = (on, config) => { // save all test results as a JSON file // https://github.com/bahmutov/cypress-json-results require('cypress-json-results')({ on, filename: 'results.json', // default filename }) // Optionally, you can also enable GitHub Actions summary or Markdown table updates // require('cypress-json-results')({ // on, // filename: false, // disable JSON file writing if only summary is needed // githubActionsSummary: 'spec', // 'spec' or 'test' // updateMarkdownFile: 'README.md' // path to the markdown file to update // }) }
Debug
Known issues
gotchaThe plugin assumes that the output directory for the specified 'filename' already exists. It will not create parent directories if they are missing.
fix
Ensure the target directory exists before running Cypress tests (e.g., create it with `mkdir -p your/output/path`).
affects: >=1.0.0
gotchaTo prevent writing a JSON file while still utilizing other features like GitHub Actions summaries or Markdown table updates, you must explicitly set the `filename` option to `false`.
fix
Configure the plugin with `{ filename: false }` if you do not want a JSON output file.
affects: >=1.3.0
gotchaWhen using `updateMarkdownFile`, the plugin relies on specific HTML comments (`<!-- cypress-test-counts -->` and `<!-- cypress-test-counts-end -->`) to locate and update the table. Incorrect or missing comments will prevent the table from being updated.
fix
Verify that the Markdown file contains the exact `<!-- cypress-test-counts -->` and `<!-- cypress-test-counts-end -->` comments surrounding your table.
affects: >=1.2.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open 'results.json'
The directory specified in the `filename` option does not exist.
fix
Create the directory manually or ensure your CI pipeline creates it before running Cypress tests. For example: `mkdir -p path/to/output`.
TypeError: require(...) is not a function
The plugin is being called incorrectly, likely outside of `cypress/plugins/index.js` or with incorrect arguments, or attempting an ES module import.
fix
Ensure `require('cypress-json-results')({ on, filename: '...' })` is called exactly once within your `cypress/plugins/index.js` file and receives the `on` and `config` objects from the plugin's `module.exports` function.
Markdown table in 'README.md' was not updated
The `updateMarkdownFile` option is set, but the required HTML comment markers (`<!-- cypress-test-counts -->` and `<!-- cypress-test-counts-end -->`) are not found or are malformed in the specified Markdown file.
fix
Check the target Markdown file (`e.g. README.md`) and ensure it contains the precise HTML comment markers `<!-- cypress-test-counts -->` and `<!-- cypress-test-counts-end -->` surrounding the table you wish to update.
Upgrade
Version history
1.5.0latest on npm
Audit
Dependencies
cypressrequiredPeer dependency, as this is a Cypress plugin that interacts with the Cypress test runner lifecycle.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
cypress-json-results — npm install cypress-json-results · libregistry