Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
cypress-log-to-output
Advanced tools
Sends all browser console logs to stdout while running your Cypress tests.
The cypress-log-to-output npm package allows you to capture and output Cypress logs to the terminal or other output streams. This is particularly useful for debugging and monitoring tests in CI environments where you may not have access to the browser's console.
Log to Terminal
This feature allows you to capture Cypress logs and print them directly to the terminal. This is useful for debugging tests in environments where you don't have access to the browser's console.
const installLogsPrinter = require('cypress-log-to-output').install;
installLogsPrinter();
Custom Log Filtering
This feature allows you to filter logs based on custom criteria. In this example, only logs that contain the word 'error' will be printed to the terminal.
const installLogsPrinter = require('cypress-log-to-output').install;
installLogsPrinter({
filterLog: (log) => log.message.includes('error')
});
Log to File
This feature allows you to capture Cypress logs and write them to a file. This is useful for keeping a persistent record of logs for later analysis.
const fs = require('fs');
const installLogsPrinter = require('cypress-log-to-output').install;
installLogsPrinter({
printLogsToFile: 'cypress-logs.txt'
});
The cypress-failed-log package captures logs for failed Cypress tests and saves them to a file. Unlike cypress-log-to-output, it focuses specifically on failed tests and provides detailed logs for debugging.
The cypress-terminal-report package captures Cypress logs and outputs them to the terminal, similar to cypress-log-to-output. However, it also provides additional features like grouping logs by test and adding custom log messages.
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.
npm install --save-dev cypress-log-to-output
In your cypress/plugins/index.js
, add this to your module.exports
:
module.exports = (on, config) => {
/** the rest of your plugins... **/
require('cypress-log-to-output').install(on)
// or, if there is already a before:browser:launch handler, use .browserLaunchHandler inside of it
// @see https://github.com/flotwig/cypress-log-to-output/issues/5
}
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.
If you want to filter events, you can use a custom filtering callback:
module.exports = (on, config) => {
/** the rest of your plugins... **/
require('cypress-log-to-output').install(on, (type, event) => {
// return true or false from this plugin to control if the event is logged
// `type` is either `console` or `browser`
// if `type` is `browser`, `event` is an object of the type `LogEntry`:
// https://chromedevtools.github.io/devtools-protocol/tot/Log#type-LogEntry
// if `type` is `console`, `event` is an object of the type passed to `Runtime.consoleAPICalled`:
// https://chromedevtools.github.io/devtools-protocol/tot/Runtime#event-consoleAPICalled
// for example, to only show error events:
if (event.level === 'error' || event.type === 'error') {
return true
}
return false
})
}
If you want to record the logs internally, you can use the recordLogs
option:
module.exports = (on, config) => {
/** the rest of your plugins... **/
const options = { recordLogs: true };
require('cypress-log-to-output').install(on, filterCallback, options)
}
The logs will be stored in an internal buffer. They can be accessed using the getLogs
exported function.
The buffer can be cleared using the clearLogs
exported function.
You can remove the lines beginning with [cypress-log-to-output]
by passing -cypress-log-to-output
in the DEBUG
environment variable.
FAQs
Sends all browser console logs to stdout while running your Cypress tests.
We found that cypress-log-to-output demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.