{"id":13050,"library":"cypress-terminal-report","title":"Cypress Terminal Report","description":"Cypress Terminal Report is a utility plugin for Cypress that significantly enhances the clarity and detail of test logs within the terminal and in output files. As of version 7.3.3, it is actively maintained and designed for Cypress versions 10.0.0 and newer. The package provides richer debug output by capturing Cypress commands, browser console logs, and network request data (cy.request, cy.intercept), which are crucial for debugging, especially in CI/CD pipelines. Key differentiators include its visually appealing console output, support for logging to files, configurable options for logging only on failure (default) or always, and features for trimming and compacting logs. It also handles multiple and nested Mocha contexts and logs commands from `before all` and `after all` hooks, offering more comprehensive insights than standard Cypress logging, making it an invaluable tool for complex testing environments.","status":"active","version":"7.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/archfz/cypress-terminal-report","tags":["javascript","terminal","cli","output","info","report","cypress","console","logs","typescript"],"install":[{"cmd":"npm install cypress-terminal-report","lang":"bash","label":"npm"},{"cmd":"yarn add cypress-terminal-report","lang":"bash","label":"yarn"},{"cmd":"pnpm add cypress-terminal-report","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core test runner that this plugin enhances.","package":"cypress","optional":false}],"imports":[{"note":"This function configures the Node.js-side plugin. It is directly required from its file path in `cypress.config.js|ts` within the `setupNodeEvents` function. For ESM in TypeScript, use `import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter'; installLogsPrinter(on);` with `esModuleInterop` enabled.","wrong":"import { installLogsPrinter } from 'cypress-terminal-report';","symbol":"installLogsPrinter","correct":"require('cypress-terminal-report/src/installLogsPrinter')(on);"},{"note":"This function initializes the client-side log collection mechanism. It is directly required from its file path in `cypress/support/e2e.js|ts`. For ESM in TypeScript, use `import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector'; installLogsCollector();` with `esModuleInterop` enabled.","wrong":"import { installLogsCollector } from 'cypress-terminal-report';","symbol":"installLogsCollector","correct":"require('cypress-terminal-report/src/installLogsCollector')();"},{"note":"This TypeScript type definition can be used to explicitly type the options object passed to `installLogsPrinter` for improved type checking and developer experience in `cypress.config.ts`.","wrong":"import { CypressTerminalReportOptions } from 'cypress-terminal-report';","symbol":"CypressTerminalReportOptions","correct":"import { CypressTerminalReportOptions } from 'cypress-terminal-report/src/options';"}],"quickstart":{"code":"// cypress.config.js or cypress.config.ts\nconst { defineConfig } = require('cypress');\nconst installLogsPrinter = require('cypress-terminal-report/src/installLogsPrinter');\n\nmodule.exports = defineConfig({\n  e2e: {\n    setupNodeEvents(on, config) {\n      // Configure the terminal reporter plugin with options\n      installLogsPrinter(on, {\n        defaultTrimLength: 500, // Trim cy.log and console logs\n        commandTrimLength: 500, // Trim Cypress commands\n        compactLogs: 5,         // Show 5 logs around failing commands\n        printLogsToConsole: 'always' // Print logs for all tests, not just failures\n      });\n      // Important: return the config object to Cypress\n      return config;\n    },\n    specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}'\n  }\n});\n\n// cypress/support/e2e.js or cypress/support/e2e.ts\nrequire('cypress-terminal-report/src/installLogsCollector')();\n\n// cypress/e2e/example.cy.ts (Example test file)\ndescribe('Cypress Terminal Report Demo', () => {\n  it('should capture various logs on success', () => {\n    cy.visit('https://example.cypress.io');\n    cy.get('h1').should('contain', 'Kitchen Sink');\n    cy.log('This is a custom message logged via cy.log.');\n    console.warn('Browser console warning captured by plugin.');\n    cy.request('GET', 'https://jsonplaceholder.typicode.com/todos/1').then((response) => {\n      expect(response.status).to.eq(200);\n      cy.log(`Fetched todo: ${response.body.title}`);\n    });\n  });\n\n  it('should highlight logs around a failure', () => {\n    cy.visit('https://example.cypress.io');\n    cy.get('#non-existent-element').should('be.visible'); // This command will fail\n    console.error('Browser console error due to a failed assertion.');\n  });\n});","lang":"typescript","description":"This quickstart demonstrates the full setup for `cypress-terminal-report`, including the Node.js plugin registration in `cypress.config.js|ts` and the client-side log collector in `cypress/support/e2e.js|ts`, along with example Cypress tests to show log capturing for both successful and failing scenarios."},"warnings":[{"fix":"Ensure your `cypress-terminal-report` version matches your Cypress installation's major version requirements. Check the `package.json` peer dependencies or the official documentation for compatibility tables.","message":"Major versions of `cypress-terminal-report` are tied to specific Cypress versions. Version `4.0.0` and above requires Cypress `>=10.0.0`. Older versions like `3.0.0` require Cypress `>=4.10.0`, and versions `<3.0.0` require Cypress `>=3.8.0`.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"To always print logs, configure the `printLogsToConsole` option to `'always'` in your `cypress.config.js|ts` when installing the plugin: `installLogsPrinter(on, { printLogsToConsole: 'always' });`","message":"By default, `cypress-terminal-report` only prints logs to the console for failing tests. This can be misleading if you expect to see full logs for every test run.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Always use `cy.log()` for logging custom messages within your Cypress test steps. Browser console logs emitted by the application under test (e.g., from `console.warn` or `console.error` in your front-end code) *will* be captured.","message":"Direct usage of `console.log` (or `console.info`, etc.) within Cypress test code will not be captured by `cypress-terminal-report` for test steps, as it bypasses Cypress's command queue. This goes against the recommended Cypress testing patterns.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Ensure `\"esModuleInterop\": true` is set under `compilerOptions` in your `tsconfig.json` to correctly handle CommonJS modules being imported via ES6 syntax (e.g., `import installLogsPrinter from '...'`).","message":"When using TypeScript with ES6 imports for the plugin or collector utilities, you might encounter issues if `esModuleInterop` is not enabled in your `tsconfig.json`.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `\"esModuleInterop\": true` in `tsconfig.json`. If using CommonJS, stick to `const installLogsPrinter = require('cypress-terminal-report/src/installLogsPrinter');`. For ESM, ensure correct default import or adjust `moduleResolution`.","cause":"Attempting to `import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter'` in a TypeScript file without `esModuleInterop` enabled, or mixing CJS `require` with ESM `import` incorrectly.","error":"TypeError: (0 , installLogsPrinter_1.default) is not a function"},{"fix":"Double-check the exact paths: `cypress-terminal-report/src/installLogsPrinter` and `cypress-terminal-report/src/installLogsCollector`. Ensure `node_modules` is correctly configured in your build system's resolution paths if using a custom setup.","cause":"Incorrect file path or module resolution issues when importing the plugin or collector in `cypress.config.js|ts` or `support/e2e.js|ts`.","error":"Error: Webpack is unable to resolve or load the module: cypress-terminal-report/src/installLogsPrinter"},{"fix":"Modify the plugin configuration in `cypress.config.js|ts` to always print logs: `installLogsPrinter(on, { printLogsToConsole: 'always' });`","cause":"The plugin's default behavior is to only print logs to the console for tests that fail, to reduce noise for passing tests.","error":"Test logs are not appearing in my terminal output for successful tests."},{"fix":"Use `cy.log('Your message')` within your Cypress test code to ensure messages are captured and displayed by `cypress-terminal-report`.","cause":"The plugin does not capture `console.log` calls made directly within the Cypress test's command queue. It primarily captures `cy.log` calls and browser-side `console` output from the application under test.","error":"Console.log statements are not appearing in the Cypress report or terminal output."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}