-
Notifications
You must be signed in to change notification settings - Fork 91
test: VSCode test setup and switch to insiders VSCODE-700 #1186
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
test: VSCode test setup and switch to insiders VSCODE-700 #1186
Conversation
66057bb to
ab321dd
Compare
src/extension.ts
Outdated
| let mdbExtension: MDBExtensionController; | ||
| let mdbExtension: MDBExtensionController | undefined; | ||
|
|
||
| const isUnderTest = process.env.MDB_UNDER_TEST === 'true'; |
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.
| const isUnderTest = process.env.MDB_UNDER_TEST === 'true'; | |
| const isUnderTest = process.env.NODE_ENV === "test" && process.env.MDB_UNDER_TEST === 'true'; |
nit and optional: Perhaps to make it more clear that this is a test only setting. Doing this would require setting the correct flag when running tests as well.
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.
maybe let's get rid of MDB_UNDER_TEST altogether and just use the NODE_ENV?
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.
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 prefer being explicit about this if you're not married to the idea of using NODE_ENV @gagik
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.
okay NODE_DEV in particular actually antipattern (TIL), although not necessarily relevant for our case: https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production
"under test" is weird wording for me though, maybe just MDB_IS_TEST?
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.
Would that create problems for us when/if we migrate to using vitest, considering it doesn't automatically set NODE_ENV? Or do we just set it ourselves?
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.
we'd set it just like any other environment variable yeah
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.
For the current setup, it actually doesn't set the NODE_ENV to "test" automatically, just FYI
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.
yeah it's just a matter of naming preferences. The real difference here is that in production environment this is pre-set to production so the variable is less random.
NODE_ENV === 'test' or MDB_IS_TEST is fine by me; but it should be one or the other imo
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.
So, as it turns out, NODE_ENV is being set to "development" by webpack. It overrides any value that is being passed as a runtime parameter. Thus, it is somewhat unclear when this variable will get hijacked by some other process, and is definitely not 100% under our full control. I would argue for keeping MDB_IS_TEST (renamed from MDB_UNDER_TEST), for consistency and full control @gagik
Co-authored-by: Himanshu Singh <himanshu.singhs@outlook.in>
a17d2b4 to
07f26cd
Compare
himanshusinghs
left a comment
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.
Looking good 🚀
| // Download VS Code, unzip it and run the integration test | ||
| await runTests({ | ||
| version: '1.103.2', // TODO(VSCODE-700) Once we fix the test setup issues, we should revert this to 'insiders' | ||
| version: 'insiders', |
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.
<3
|
Feel free to merge whenever you've addressed the open comment. |
gagik
left a comment
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.
Haven't looked at rest too thoroughly but MDB_IS_TEST sgtm!

Description
The problem was: The vscode test setup is failing with both
stableandinsidersbuilds and that is because the recent changes from VSCode does not allow having multiple providers for a registered scheme.Several people attempted a solution, and I got feedback to try to remove the MDBExtensionController stub, and instead use the actual controller that is initialized in the src/extension.ts file. This seemed like a good solution, but it caused more problems than it solved:
After doing a thorough exploration in mitigation of above mentioned problems, I concluded that this cannot be the way forward. Aside from everything in the system working against this solution, it would also require an update to many of the current unit tests (about 60 at a minimum).
I though about opening a ticket directly on VSCode github page, but with over 13k open issues, I figured it might not be the optimal solution. Googling for the exact error I was getting when using insiders build returned no exact matches, and tracking down even a StackOverflow thread with the similar issue proved difficult.
For all these reasons I concluded that the solution is either extremely complex, or incredibly trivial.
I went for incredibly trivial, and this PR is that solution.
Using a env flag prevents the real controller from being registered when running tests, and registers ONLY the stubbed one instead. It seems to resolve the issue, and the unit tests run normally.
There were some issues when running via the VSCode UI, which pertain to specific test cases, so I had to update those as well.
It was all down to multiple registration/initializations, incomplete test cleanup which caused the first run to be successful, but the subsequent ones to fail, and few other minor things.
In summation, we can now run test from CLI or VSCode UI, the github actions are all working. The version we test against is now "insiders" again.
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes