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

Allow non-escaped HTML to be used as an assertion message #1718

Open
david-pfx opened this issue Jun 23, 2023 · 1 comment
Open

Allow non-escaped HTML to be used as an assertion message #1718

david-pfx opened this issue Jun 23, 2023 · 1 comment
Labels
Category: API Component: CLI Type: Enhancement Type: Meta Seek input from maintainers and contributors.

Comments

@david-pfx
Copy link

Using 2.19.4, Windows, browser
New feature: config option to bypass the call to EscapeText at around line 5783:

      var message = escapeText(details.message) || (details.result ? 'okay' : 'failed');

Very useful feature to put formatting and links in assertion messages.

@Krinkle
Copy link
Member

Krinkle commented Jul 3, 2023

@david-pfx I'm interested in exploring this, and like the idea of allowing rich text formatting. This would unlock many interesting features.

QUnit output is often passed through (or presented in) contexts where there is no HTML support. For example, most CI systems these days present build output as plain text (Jenkins, Travis CI, GitHub Actions, etc.). This includes e.g. when one uses cross-browser runners such as Karma, Headless Chrome via grunt-contrib-qunit, cloud browsers such via browserstack-runner, or e.g. when using QUnit to test a Node.js package.

Other examples exist within the browser, when using the TAP reporter, which prints to the browser console. While this is testing frontend JavaScript inside a browser, the web page is empty, with the QUnit results printed in the browser console.

If your need is mainly to make links clickable, perhaps an alternative would be for QUnit to do what browsers, terminals, and CI systems also do with their output - they automaticlaly scan for URLs in the plain text, and turn them into clickable links. Would that work for you?

A few other ideas based on your HTML proposal:

  • QUnit could render the HTML code as unparsed HTML in these contexts. This seems suboptimal as that would look broken.
  • QUnit could try to strip the HTML tags and render the remaining text. This would be fine for simple text styling, but for links this would make the URL inaccessible.
  • QUnit could require that, if you specify an HTML message, that you also specify a plain text version. This would place extra work on developers and make for a more complicated Assertion API.

@Krinkle Krinkle added Category: API Type: Enhancement Type: Meta Seek input from maintainers and contributors. Component: CLI labels Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Component: CLI Type: Enhancement Type: Meta Seek input from maintainers and contributors.
Development

No branches or pull requests

2 participants