• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    JavaScript
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Cypress plugin that sends all logs that occur in the browser to stdout in the terminal.

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) => {
  /** 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

Screen Shot 2019-05-20 at 3 01 12 PM

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) => {
  /** 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
  })
}

Recording Logs

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.

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.

More Repositories

1

the-one-cert

One cert to rule them all: SSL cert that is valid for any and all domains + all levels of subdomains
JavaScript
804
star
2

spotify-now-playing-on-github

Update your GitHub user status with what you're listening to on Spotify!
TypeScript
54
star
3

TLDR-2

TLDR 2 (TLD Records 2) is a continually updated DNS archive of zone transfer attempts against all existing TLD nameservers as well as the root servers.
Python
49
star
4

pilo

RPi-powered lights-out management for servers. Remotely control the keyboard, power, and see the screen of a server.
TypeScript
38
star
5

zone-walks

A collection of domain lists obtained from zone-walking TLDs. Updated daily.
Shell
15
star
6

StatsBot

📈 Chat bot which logs conversations on IRC for analysis by pisg.
Ruby
11
star
7

360api-gae

🎮 Python REST API for Xbox Gamercard information, built to run on the Google App Engine.
Python
11
star
8

suphpbot

🔥 [TERRIBLE CODE] A simple, non-OOP, modular IRC bot. Written in PHP.
PHP
10
star
9

upmon

🚦 A simple, easy to use PHP-based uptime monitor with grouped HTML, PNG and JSON output options.
PHP
7
star
10

spoofident

👥 An identd which serves spoofed responses to requests for identity information.
Python
7
star
11

markdown-notebooks

Create markdown-based notebooks stored in Gists with image support
JavaScript
6
star
12

osTicket-Equipment

This will be an osTicket plugin for managing equipment inventory and lending.
PHP
6
star
13

zone-walker

A CLI tool that walks through DNS zones using NSEC responses and write found domains to stdout.
JavaScript
6
star
14

disposable-email-addresses

📫 The largest public list of disposable email address domains. 1000+ domains, no duplicates.
5
star
15

get-touching-prs

A module + CLI tool that helps you find open GitHub pull requests that modify certain files.
TypeScript
4
star
16

gamercard

Xbox 360 Gamercard Creator
JavaScript
4
star
17

python-kraken

💱 Python class to read the Kraken Bitcoin Exchange API
Python
3
star
18

site

My personal website built in Jekyll, Liquid, and good old HTML5.
HTML
3
star
19

webtools

http://za.chary.us/projects/webtools
PHP
3
star
20

Pulse-Notify

Take incoming notifications on an Android device and stream them to the JBL Pulse 2's LED grid.
Java
2
star
21

paste

A secure pastebin module for SiteSense with password-based paste encryption, extensible syntax highlighting, and more.
PHP
2
star
22

gitlab-ci-github-status-checks

Small HTTP server that updates GitHub commit status checks on GitLab job status webhook events.
JavaScript
2
star
23

Pi-Dartboard

A real-life dartboard that keeps track of score via Raspberry Pi. Supports various game modes.
C
2
star
24

ShortUrls

A Ruby URL shortener class with an HTTP implementation
Ruby
2
star
25

electron-worker-threads-sigabrt-repro

Repro for Electron SIGABRT issue with worker_threads
JavaScript
1
star
26

cs3630-lab

A set of labs for the Cozmo robot written for CS 3630 Robotics and Perception at Georgia Tech.
Python
1
star
27

keycodes-to-ps2-scan-codes

Convert Web API keyCodes to PS/2 keyboard scan codes (set 2).
JavaScript
1
star
28

what-is-circular

Like is-circular, but returns the path to the first circular reference found.
JavaScript
1
star
29

node-streaming-markov-chain-builder

A Markov chain builder that accepts input text as a stream and outputs a stream of n-grams.
TypeScript
1
star
30

imdb-scraper

🎥 IMDb.com scraper using Express (to expose an API), Redis (for caching), and Cheerio (for parsing)
JavaScript
1
star
31

terra

JavaScript
1
star
32

GTAV-Motion

🚓 A mod for GTAV to enable motion control.
C++
1
star
33

git-mirror-docker

Docker image for mirroring GitHub repos to GitLab/other Git remotes on a push webhook event from a GitHub repo.
Dockerfile
1
star