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-logVerified import paths — ran on the pinned version, not inferred.
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.
Ensure `require('cypress-failed-log/on')(on);` is called inside `e2e.setupNodeEvents(on, config)` in your `cypress.config.js`.Implement custom screenshot logic using Cypress's `after:spec` or `after:run` events if screenshotting on failure is required.
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.
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`.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.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.