karma-runner / karma-runner/karma

Support console.dir for pretty-printed object dumps when captureConsole=true

Open
#1,763 1 comment 10 reactions 0 assignees View on GitHub
help wanted type: feature
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Sometimes when debugging I want to dump to console a pretty-printed object.

Normally in browser I'd use `console.dir`. In karma, this prints nothing, since `dir` is not listed [here](https://github.com/karma-runner/karma/blob/master/client/karma.js#L70).
I can use `console.dir` but the output is an ugly non-readable one-liner.

So the scope of this issue would be to
1) enable logging for `console.dir` when `captureConsole` is `true`
2) enhance a stringifier to be whitespace-aware (behing the flag), and pass that flag to the stringifier when logging from `console.dir`.
3) maybe also change the depth in case of `console.dir` to be more than `3`.

Would you be interested in receiving a PR with those changes?

Contributor guide

Open the contributing guide

Research direction

Start in client/karma.js, where the issue notes that console methods are listed, then trace the console-capture path and locate the stringifier used for logged values. Done means console.dir is captured when captureConsole is true and can produce whitespace-aware pretty output, with any depth change validated against the existing console behavior and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.