Registry / testing / cypress-failed-log

cypress-failed-log

JSON →
library2.10.0jsnpmunverified

cypress-failed-log is a Cypress utility that captures the command log as JSON whenever a test fails. It outputs these commands directly to the terminal for immediate visibility and saves a detailed JSON file (including spec name, test title, error message, and command array) to a `cypress/logs/` directory. The current stable version is v2.10.0, with releases occurring on an as-needed basis primarily to maintain compatibility with new Cypress versions or to fix bugs. Its key differentiator is providing structured, machine-readable command logs for failed tests, significantly aiding in debugging and integration with reporting tools, offering more detail than standard Cypress failure outputs.

npm install cypress-failed-log
INSTALL
IMPORT
SIG · CYPRESS-FAILED-LOG
C
cypress-failed-log
testingjavascriptv2.10.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.

CypressFailedLog
import 'cypress-failed-log'
const cypressFailedLog = require('cypress-failed-log')
For integrating with Cypress's support file (e.g., `cypress/support/e2e.js`) using ESM syntax. The `require` syntax is also valid in CJS environments.
registerCypressFailedLogOn
require('cypress-failed-log/on')(on)
import registerCypressFailedLogOn from 'cypress-failed-log/on'
This specific CommonJS `require` pattern is used to hook into Cypress's Node events in `cypress.config.js`, especially recommended for Cypress v10+.

Installs the package and configures it in Cypress's support file and `cypress.config.js` to automatically log failed test commands to the terminal and as JSON files.

npm install --save-dev cypress cypress-failed-log // cypress/support/e2e.ts or cypress/support/e2e.js import 'cypress-failed-log'; // cypress.config.ts or cypress.config.js import { defineConfig } from 'cypress'; module.exports = defineConfig({ defaultCommandTimeout: 500, e2e: { setupNodeEvents(on, config) { // This is essential for Cypress v10+ to enable saving JSON logs require('cypress-failed-log/on')(on); }, }, });
Debug
Known issues
breakingFor Cypress v10 and newer, the plugin must be initialized within the `setupNodeEvents` function in `cypress.config.js`. Previous integration methods in `plugins/index.js` will no longer work.
fix
Ensure `require('cypress-failed-log/on')(on);` is called inside `e2e.setupNodeEvents(on, config)` in your `cypress.config.js`.
affects: >=2.10.0
breakingThe functionality for screenshotting failed tests was removed in version 2.7.0. If your workflow relied on `cypress-failed-log` producing screenshots, this feature is no longer available.
fix
Implement custom screenshot logic using Cypress's `after:spec` or `after:run` events if screenshotting on failure is required.
affects: >=2.7.0
gotchaSince version 2.9.4, log files are only saved if it's the *last* attempt of a retried test. Intermediate failed attempts will not produce log files.
fix
Be aware of this change when debugging tests with retries. Logs will only reflect the final failure state. If you need logs from every attempt, consider custom reporting or logging within Cypress's `after:test:run` hook.
affects: >=2.9.4
Errors
Common errors & fixes
Cypress failed log JSON files are not being generated in `cypress/logs/`.
The plugin's `on` events might not be correctly registered in `cypress.config.js`, especially after upgrading to Cypress v10+.
fix
Verify that `require('cypress-failed-log/on')(on);` is present and correctly configured within the `setupNodeEvents` function for your e2e tests in `cypress.config.js`.
Cypress command logs are not appearing in the terminal on test failure.
The `cypress-failed-log` module is not correctly imported or required in your Cypress support file (e.g., `cypress/support/e2e.js` or `e2e.ts`).
fix
Add `import 'cypress-failed-log';` (for ESM) or `require('cypress-failed-log');` (for CJS) to your main Cypress support file to activate the terminal logging.
Error: Timed out retrying: Expected to find content: '...' but never did. (and no detailed command log).
While Cypress provides its own error messages, the detailed command log from `cypress-failed-log` might be missing if the plugin isn't fully integrated, masking the exact sequence of commands leading to the timeout.
fix
Ensure both `cypress-failed-log` in the support file and `cypress-failed-log/on` in `cypress.config.js` are correctly set up to capture comprehensive logs for debugging the sequence of commands before the timeout.
Upgrade
Version history
2.10.0latest on npm
Audit
Dependencies
cypressrequiredPeer dependency, as this is a Cypress plugin that hooks into the test runner lifecycle.
debugrequiredRuntime dependency used for internal logging and debugging, as noted in dependency updates.
logdownrequiredRuntime dependency used for console logging, as noted in dependency updates.
Agent activity
12 hits · last 30 days
node
12
Resources
cypress-failed-log — npm install cypress-failed-log · libregistry