{"id":13040,"library":"cypress-failed-log","title":"Cypress Failed Log","description":"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.","status":"active","version":"2.10.0","language":"javascript","source_language":"en","source_url":"https://github.com/bahmutov/cypress-failed-log","tags":["javascript","cypress","fail","json","log","report","utility"],"install":[{"cmd":"npm install cypress-failed-log","lang":"bash","label":"npm"},{"cmd":"yarn add cypress-failed-log","lang":"bash","label":"yarn"},{"cmd":"pnpm add cypress-failed-log","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, as this is a Cypress plugin that hooks into the test runner lifecycle.","package":"cypress","optional":false},{"reason":"Runtime dependency used for internal logging and debugging, as noted in dependency updates.","package":"debug","optional":false},{"reason":"Runtime dependency used for console logging, as noted in dependency updates.","package":"logdown","optional":false}],"imports":[{"note":"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.","wrong":"const cypressFailedLog = require('cypress-failed-log')","symbol":"CypressFailedLog","correct":"import 'cypress-failed-log'"},{"note":"This specific CommonJS `require` pattern is used to hook into Cypress's Node events in `cypress.config.js`, especially recommended for Cypress v10+.","wrong":"import registerCypressFailedLogOn from 'cypress-failed-log/on'","symbol":"registerCypressFailedLogOn","correct":"require('cypress-failed-log/on')(on)"}],"quickstart":{"code":"npm install --save-dev cypress cypress-failed-log\n\n// cypress/support/e2e.ts or cypress/support/e2e.js\nimport 'cypress-failed-log';\n\n// cypress.config.ts or cypress.config.js\nimport { defineConfig } from 'cypress';\n\nmodule.exports = defineConfig({\n  defaultCommandTimeout: 500,\n  e2e: {\n    setupNodeEvents(on, config) {\n      // This is essential for Cypress v10+ to enable saving JSON logs\n      require('cypress-failed-log/on')(on);\n    },\n  },\n});\n","lang":"typescript","description":"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."},"warnings":[{"fix":"Ensure `require('cypress-failed-log/on')(on);` is called inside `e2e.setupNodeEvents(on, config)` in your `cypress.config.js`.","message":"For 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.","severity":"breaking","affected_versions":">=2.10.0"},{"fix":"Implement custom screenshot logic using Cypress's `after:spec` or `after:run` events if screenshotting on failure is required.","message":"The 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.","severity":"breaking","affected_versions":">=2.7.0"},{"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.","message":"Since 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.","severity":"gotcha","affected_versions":">=2.9.4"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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`.","cause":"The plugin's `on` events might not be correctly registered in `cypress.config.js`, especially after upgrading to Cypress v10+.","error":"Cypress failed log JSON files are not being generated in `cypress/logs/`."},{"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.","cause":"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`).","error":"Cypress command logs are not appearing in the terminal on test failure."},{"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.","cause":"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.","error":"Error: Timed out retrying: Expected to find content: '...' but never did. (and no detailed command log)."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}