Registry / testing / cypress-terminal-report

cypress-terminal-report

JSON →
library7.3.3jsnpmunverified

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.

npm install cypress-terminal-report
INSTALL
IMPORT
SIG · CYPRESS-TERMINAL-R
C
cypress-terminal-report
testingjavascriptv7.3.3
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.

installLogsPrinter
require('cypress-terminal-report/src/installLogsPrinter')(on);
import { installLogsPrinter } from 'cypress-terminal-report';
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.
installLogsCollector
require('cypress-terminal-report/src/installLogsCollector')();
import { installLogsCollector } from 'cypress-terminal-report';
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.
CypressTerminalReportOptions
import { CypressTerminalReportOptions } from 'cypress-terminal-report/src/options';
import { CypressTerminalReportOptions } from 'cypress-terminal-report';
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`.

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.

// cypress.config.js or cypress.config.ts const { defineConfig } = require('cypress'); const installLogsPrinter = require('cypress-terminal-report/src/installLogsPrinter'); module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { // Configure the terminal reporter plugin with options installLogsPrinter(on, { defaultTrimLength: 500, // Trim cy.log and console logs commandTrimLength: 500, // Trim Cypress commands compactLogs: 5, // Show 5 logs around failing commands printLogsToConsole: 'always' // Print logs for all tests, not just failures }); // Important: return the config object to Cypress return config; }, specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}' } }); // cypress/support/e2e.js or cypress/support/e2e.ts require('cypress-terminal-report/src/installLogsCollector')(); // cypress/e2e/example.cy.ts (Example test file) describe('Cypress Terminal Report Demo', () => { it('should capture various logs on success', () => { cy.visit('https://example.cypress.io'); cy.get('h1').should('contain', 'Kitchen Sink'); cy.log('This is a custom message logged via cy.log.'); console.warn('Browser console warning captured by plugin.'); cy.request('GET', 'https://jsonplaceholder.typicode.com/todos/1').then((response) => { expect(response.status).to.eq(200); cy.log(`Fetched todo: ${response.body.title}`); }); }); it('should highlight logs around a failure', () => { cy.visit('https://example.cypress.io'); cy.get('#non-existent-element').should('be.visible'); // This command will fail console.error('Browser console error due to a failed assertion.'); }); });
Debug
Known issues
breakingMajor 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`.
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.
affects: >=3.0.0
gotchaBy 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.
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' });`
affects: >=3.0.0
gotchaDirect 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.
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.
affects: >=3.0.0
gotchaWhen using TypeScript with ES6 imports for the plugin or collector utilities, you might encounter issues if `esModuleInterop` is not enabled in your `tsconfig.json`.
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 '...'`).
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: (0 , installLogsPrinter_1.default) is not a function
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.
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`.
Error: Webpack is unable to resolve or load the module: cypress-terminal-report/src/installLogsPrinter
Incorrect file path or module resolution issues when importing the plugin or collector in `cypress.config.js|ts` or `support/e2e.js|ts`.
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.
Test logs are not appearing in my terminal output for successful tests.
The plugin's default behavior is to only print logs to the console for tests that fail, to reduce noise for passing tests.
fix
Modify the plugin configuration in `cypress.config.js|ts` to always print logs: `installLogsPrinter(on, { printLogsToConsole: 'always' });`
Console.log statements are not appearing in the Cypress report or terminal output.
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.
fix
Use `cy.log('Your message')` within your Cypress test code to ensure messages are captured and displayed by `cypress-terminal-report`.
Upgrade
Version history
7.3.3latest on npm
Audit
Dependencies
cypressrequiredCore test runner that this plugin enhances.
Agent activity
4 hits · last 30 days
node
4
Resources