Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: disable default logging #1671

Closed
ShaMan123 opened this issue Feb 14, 2022 · 7 comments
Closed

cli: disable default logging #1671

ShaMan123 opened this issue Feb 14, 2022 · 7 comments
Labels
Component: CLI Type: Enhancement New idea or feature request.

Comments

@ShaMan123
Copy link
Contributor

ShaMan123 commented Feb 14, 2022

Tell us about your runtime:

  • QUnit version: latest
  • Which environment are you using? (e.g., browser, Node): node
  • How are you running QUnit? (e.g., QUnit CLI, Grunt, Karma, manually in browser): qunit cli

What are you trying to do?

I want to override the default logging of qunit
It isn't clear how to do so.
I do understand how to add logging.
My tests dump too much data and it becomes useless.

Used

//  https://api.qunitjs.com/extension/QUnit.dump.parse/
QUnit.dump.maxDepth = 1;

But it's not enough

Workaround

override assertions

QUnit.assert.equal = function (actual, expected, message) {
  this.pushResult({
    result: actual == expected,
    actual: getLoggingRepresentation(actual),
    expected: getLoggingRepresentation(expected),
    message
  });
};
@ShaMan123
Copy link
Contributor Author

I think a diff output for deepEqual is much more desirable instead of dumping actual and expected

@Krinkle Krinkle added Component: CLI Type: Enhancement New idea or feature request. labels Feb 14, 2022
@ShaMan123
Copy link
Contributor Author

And if I'm at it coloring is an important feature (chalk)

@ShaMan123
Copy link
Contributor Author

and this as well QUnit.config.hidepassed

@Krinkle
Copy link
Member

Krinkle commented Feb 14, 2022

Thank for creating the issue. The QUnit.dump.maxDepth works as expected I believe, and is covered with tests as well. The QUnit.dump method is used by the HTML Reporter, where this works:

Example: https://codepen.io/Krinkle/pen/yLPXmEo.

The TAP reporter, as used in the CLI by default, doesn't yet ship a differ by default. The issue for that is #1412, and a a related proposal for assertion plugins to provide a custom diff to render certain domain-specific values in a more optimal manner (#1005).

@ShaMan123
Copy link
Contributor Author

Another thing is that the cli should accept a module flag and set QUnit.config.module to the passed value
It's an easy fix, I would PR but I don't understand where the file is located.

@Krinkle
Copy link
Member

Krinkle commented Apr 24, 2022

I propose we try to use the same differ as we use in the browser and colorise it with kleur console sequences instead of HTML tags. The abstraction is there already. We may want to solve #1005 at the same time, eg produce the diff inside core instead of separately in HTML and TAP, and then have HTML/TAP only serialise the diff.

I'm tentatively closing this in favour of #1412, as my understanding is that having a diff and being able to use maxDepth is the desired outcome, not per-se the ability to disable logging.

If you do want to customise or replace logging entirely, one can use --reporter and/or pipe it to a generic TAP transformer that minimises output.

@Krinkle Krinkle closed this as completed Apr 24, 2022
@ShaMan123
Copy link
Contributor Author

I'm tentatively closing this in favour of #1412, as my understanding is that having a diff and being able to use maxDepth is the desired outcome, not per-se the ability to disable logging.

Absolutely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CLI Type: Enhancement New idea or feature request.
Development

No branches or pull requests

2 participants