ipatalas / vscode-postfix-ts

Postfix notation for TypeScript/Javascript - extension for VS Code
MIT License
158 stars 43 forks source link

Modernize tests #104

Open zardoy opened 1 year ago

zardoy commented 1 year ago

Hi! I want to record a general issue of my thoughts about your testbase and difficulties that I faced so far.

For me it always wasnt easy to define or read multiline tests with >> format. Its not that hard to define new tests with column-edit, but IMO its better to define them in a way with syntax highlight support, so its easier to read / change and paste for new contributors.

Just compare:

Screenshot 2023-01-26 at 00 29 18

Its just a proposal so feel free to decline it if you have a reason for this format.

Btw I was wondering for along time why some tests are using trimWhitespaces option?

ipatalas commented 1 year ago

Hmm, I like the idea but have mixed feelings. The old way was better in a way that you can see the code before and after side by side and it was quite easy to read (for me). In this case it's one below another but I can see the benefits of having this syntax highlight because this code is so much easier to read than when it's plain string. Let me think about it. I think this could be done as an another overload so that we still have option to use the old way for tests where it could make more sense.

Btw I was wondering for along time why some tests are using trimWhitespaces option?

If I remember correctly it was originally added for all templates which introduce blocks with curly braces. That was because VSCode was formatting that code by default when executing the template and it was harder to write an assert for that. I'm not 100% sure it's really needed for all tests which contain it now (might have been too much copy-paste somewhere). Now when I think about it it should be possible to turn this feature off for tests and then this wouldn't be necessary at all.

zardoy commented 1 year ago

In this case it's one below another but I can see the benefits of having this syntax highlight because this code is so much easier to read than when it's plain string. Let me think about it.

This traditional format definitely has even more advantages for bigger test strings, but probably the biggest advantage is that you can instantly see postfix location (in screenshot above I used block comment for it), in both cases you need to format string manually but in old way you need to more work in inserting spaces, though I don't mind both