denoland / denoland/std

Shorter message for simple assertion failures

Open
#6,645 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

**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](https://github.com/user-attachments/assets/765bddc7-abd3-4bbd-8283-537f9c3d3559)

which can be clicked on to get the full error message

![Image](https://github.com/user-attachments/assets/5364745f-f472-4210-b3be-bbbfcb4aa5ca)

**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](https://github.com/user-attachments/assets/658121d3-21de-4e9d-bde9-f46ce8fe2b3b)

![Image](https://github.com/user-attachments/assets/ff1473f7-d93c-4778-b4f7-95f594e54ef2)

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.