deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

Shorter message for simple assertion failures

Open stefnotch opened this issue 6 months ago • 0 comments

Is your feature request related to a problem? Please describe.

I use assertEquals quite often in my tests When running from VSCode, I get this little tooltip

Image

which can be clicked on to get the full error message

Image

Describe the solution you'd like

I wish I didn't always have to click on the message. It'd be lovely if it would display a variation of the following for short messages

Image

Image

This is actually pretty straightforward to implement. It's roughly

let message;
  if (actualString.length + expectedString.length <= 32) {
    message = `${actualString} != ${expectedString}${msgSuffix}`;
  } else {
    message = `Values are not equal${msgSuffix}`;
  }

Describe alternatives you've considered

  • Write my own assertEquals.

  • Just accept the one extra click.

  • Hook up the expected and actual values in the Deno LSP and report it to the UI that way. Part of the code for that is already in the LSP.

stefnotch avatar May 08 '25 22:05 stefnotch