-
Notifications
You must be signed in to change notification settings - Fork 56
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
Mocha drive letter case sensitivity bug #136
Comments
Casing bugs are always lovely 😆 Is this the same as #134? |
This bug is about making your tests work until the mocha bug is fixed, so yes, they are related. |
Hello folks. I'm running into a similar issue, but I'm not sure how I can implement a workaround. I'm using a
When I run
Basically a piece of code in the test is reading a global variable exported by a module from the extension under test, and this global variable is unexpectedly Some more digging showed that calling
Note how it's
It fails again. That's how I figured out it may be related to this issue. However in my case I don't have an So now my issue is: how do I run all tests? That's typically done by simply calling Any ideas? Thanks! |
Are you able to share more info so I can try to reproduce the problem you're seeing? |
Let me see if I can reproduce the problem with the sample CLI project |
I managed to reproduce on a fork of the sample test CLI project First I got the following problem when running from the VS Code Testing view:
However I'd already seen this, but can't find the relevant GitHub issue now. A Next I updated the test to make use of global variables exposed by the extension module. The test passed in when launched from the Testing view of VS Code because that uses However when I try launching from a PowerShell in that directory, I get this:
Note that I've had to remove the
Let me know if you need more information. I'd be interested in seeing if you can reproduce the issue! Thanks |
Oh and here are my OS specs if that's relevant Edition Windows Server 2022 Datacenter And
|
Hm, I'm not able to repro this. Here's what I'm trying, is that different that what you're doing? https://github.com/microsoft/vscode-extension-samples/tree/connor412/try-repro/helloworld-test-cli-sample |
I may have used the wrong terminology as I am new to JS. Apologies. I talked about a global variable when I should be talking about a module export. |
It seems like if the upper-cased drive letter is used we end up importing the module twice, which is evident when adding a top-level console.log to extension.ts
@alexdima this seems like something the loader should handle, or should we do some treatment for the extension tests URI first? |
Pending a fix, is there a workaround that would allow me to run The only thing I've seen work is passing Can you think of something more practical? |
After some fiddling around, I was able to find a simpler workaround which is to spawn the node process in a way that makes the current work directory use a lowercase drive letter. I managed to do that with the following Python script: from pathlib import Path
import subprocess
cwd = Path().absolute()
# Convert the path to a lowercase drive letter
cwd = Path(f"{cwd.drive.lower()}\\", *cwd.parts[1:])
cmd = ["npm", "run", "test"]
exit(subprocess.call(cmd, cwd=cwd, shell=True)) |
I found a mocha bug that is fixed with the following hack, so you might want to add this to your sample
index.ts
files:The text was updated successfully, but these errors were encountered: