cypress-log-to-output
This is a Cypress plugin that sends all console logs that occur in the browser to stdout in the terminal. This means that you can see any kind of console.log
, console.info
or console.error
that occurs in the browser, even if your tests are running in the terminal.
Installation
npm install --save-dev cypress-log-to-output
Usage
In your cypress/plugins/index.js
, add this to your module.exports
:
module.exports = (on, config) => {
require('cypress-log-to-output').install(on)
}
You'll now see all browser console logs in your terminal output.
cypress run --browser=chrome
Works in Chrome, Chromium, or Canary browsers during cypress run
and cypress open
.
Electron is not currently supported. I can't find a way to attach the Chrome Debugging Protocol to the Electron browser spawned by Cypress.
Filtering Events
If you want to filter events, you can use a custom filtering callback:
module.exports = (on, config) => {
require('cypress-log-to-output').install(on, (type, event) => {
if (event.level === 'error' || event.type === 'error') {
return true
}
return false
})
}
Disabling debug info
You can remove the lines beginning with [cypress-log-to-output]
by passing -cypress-log-to-output
in the DEBUG
environment variable.