-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Internal: Configure tests on a per-test basis #49
Conversation
I am curious about the "Failing" tests, not quite sure if they should be in here but rather listed out as issues... |
6abe20d
to
a438199
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about putting snapshot files next to source? some thing like
jsfmt.spec.js
input.twig
input.snap.twig
Or we can use .snap
as file extension, but we might lose syntax hightlighting on the editor. I think this will make it easier to compare the input with expected output.
This is very easy to configure, I actually started it like this as it resembles the I'll continue down this path for now, and once this is passing all tests i'll look at restructuring it. Confirming though, you're happy with a snapshot file that is in a twig format instead of just exporting a string in a JS file? |
b4e21df
to
6ba19c4
Compare
6ba19c4
to
9d5398e
Compare
I would suggest checking this out and having a bit of a play, perhaps even writing a new test or two. If you want me to remove the Do you have an opinion on whether every test should have an associated snapshot? I think it would be useful for some tests just confirming for a "no-change" so instead of comparing to the snapshot it would just be testing |
yes, having snapshot file as twig file will make it easier compare via |
tests/Comments/jsfmt.spec.js
Outdated
await expect(actual).toMatchFileSnapshot(snapshotFile); | ||
}); | ||
|
||
it("should handle html comments", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"should handle twig comments"
jsconfig.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with jsconfig stuff. Is this vscode specific features or it being used by other tools. I'm courious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it actually stems from TypeScript, but is tied closely to VScode since it supports some aspects of TypeScript within JS from an IDE perspective.
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html.
<!-- This is the story of a little lamb | ||
that gets lost in a dark forest and | ||
struggles to find home --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having extra whitespace after <!--
and berfore -->
on multiline html comment. Is this the expected output? I never write multiline comment. The old snapshot seems to be that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought this was a little odd, as well as some of the other tests.
I have gone for the approach of matching the current snapshots. But an alternate way would be that we have some tests that are skipped, and set up the snapshot to be a more "expected" output, which would give some good milestones for a v1 release.
I don't have strong oponion on this. Either way is fine.
If the test doesn't change anything, I think it's fine not to include snapshot file. |
Do you have anything to add? I think this is ready to be merged. We can deal other "inconsistency" on other PR. Before that, please rebase so I can fast-forward merge. Thanks. |
If you're happy with the change in the src/melody/melody-extension-core/visitors/filters.js file, then it should be all good to go. |
LGTM. |
Just before you merge, I have a POC to add some better type hinting with JSdoc for utilizing the function within tests and getting the twig options combined with the prettier options. I'll push this up then it should be ready. |
145fd57
to
c5f7c67
Compare
c5f7c67
to
3354cca
Compare
🚀 |
Tests can't be configured with prettier options on a per-test basis #43
🏗️ this is still under construction but I wanted to get the draft PR in to explain a bit.
The way this is working at the moment in the pull request is instead of writing to a
jsfmt.snap.js
file, it is using theexpec.toMatchFileSnapshot()
method. https://vitest.dev/guide/snapshot#file-snapshotsSee the current status of the files to see how that looks.
I have also got this working in a way that is more consistent with how it was setup before, by having one snapshot that will contain all of the tests. See the below screenshot for how that would work.
I could go either way on this, neither really change the workflow and the snapshot can be updated by passing the -u flag.