-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add test scaffolding for vscode-graphql-syntax (option 2) #3273
Conversation
|
@AaronMoat oh this is very nice, and very easy to read! In general, writing tests for anything vscode related will involve complicated test tooling, but this seems like it will really do the trick! |
I wonder why this doesn't seem to trigger a codecov report? |
weird, i don't see the comment for some reason ! but yes looking at the diff, no new coverage data I guess it makes sense, as istanbul (or whatever jest uses now) wouldn't have a way to instrument JSON for coverage in any way it could recognize. That's ok though, coverage data is only a rough metric for code quality, I think we can all agree how important this test suite is! |
@acao no comment - I was clicking through to the github actions 'details' :) ![]() |
So @acao seems you're a fan of this approach over the other one. Is that right - should I close off the other one and prefer this? I might flesh it out with a few more test examples. Do you prefer inline snapshots or proper snapshots? There's a few options
Any thoughts on that as well? |
all very good questions! I'm not sure I am ready to decide yet, and I'd be interested in what my colleagues think as well |
@AaronMoat Nicely job, thanks for putting effort into this. I prefer this PR rather than the first one. (I found here more readable) But to be honest it's not exactly what I am searching for. The goal of this PR is to test tokenizing right? We can still keep it, it's a good job. (let me know if I am right in terms I am still new to this project and still learning 😅) But I have in mind to have I was inspired by these image tests in satori https://github.com/vercel/satori/tree/main/test/image_snapshots |
I prefer the first one
|
@B2o5T great idea! I've built some custom image snapshot tooling before, for a geospatial project. that might be the most readable option. the underlying libraries for image diffing used by percy and these jest plugins are quite surprisingly simple and powerful the problem herein is that we have to find a way to render an image of the syntax highlighting in the first place. monaco for example uses a different grammar than vscode, but I'm sure we can find a library to render vscode grammars somewhere |
exactly! I found image snapshots, the most maintainable option
you have a point, this is most trickiest part :) |
Fully agree that images would be better. The how is the big question :) |
I think I'll just build this library and a set of runners (cypress, playwright, etc) for fun 😜 Shared Steps
test assertpixelmatch against each SVG, exit non 0 if pixelalmatch doesn't match, write out failing pixelmatch results with res error highlighting for the diff snap updatesave svg output |
Here is another upcoming issue, you may have mentioned already, is that there are multiple issues regarding embedded languages: and this:
which I believe will mean that not to fret though, being able to test just our rules for update: I think I misread or the readme is out of date, I think |
looking to carbon for inspiration on code -> image front, and I found this! haha! |
here is a nice rust library that seems to use modern stdout features to print code without a browser at all. the problem I anticipate is that this rendering will be inconsistent across various local and CI environments |
after some research, vscode is one of the few web IDEs that supports |
we will figure out how to track vitest coverage later
just added more tests cases and organized things a bit. lets go with this strategy for now so we have something to make improvements on and to use as a regression suite until we figure out a good solution for using images. i think shiki supports injection rules, which is heavily based on vscode-textmate |
Resolves: #2343
Alternative to #3267 using much more custom code, but I think it gives us more control. Very keen to see what people think!