-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Tests are being run with NODE_ENV=development #305
Comments
|
Not while running tests via the extension, because my tests that rely on this are failing (because of that). Running the same tests via the Vitest CLI works. |
In fact, logging This is then also the source of my WebSocket issue because my tests are createing Vite dev server middleware in case of |
Here's the repro: https://github.com/silvenon/repro/tree/vitest-extension-node-env |
It looks like export async function startVitest(...): Promise<Vitest | undefined> {
process.env.TEST = 'true'
process.env.VITEST = 'true'
process.env.NODE_ENV ??= 'test'
...
const ctx = await createVitest(mode, options, viteOverrides, vitestOptions) When For the time being, I think using // .vscode/settings.json
{
"vitest.nodeEnv": {
"NODE_ENV": "test"
}
} I'm not sure where the fix should belong to. Whether adding the same I'm thinking we can fix |
Describe the bug
I had two problems when testing my Express server with
supertest
with the pre-release of the extension, this was one of them. I'm aware ofprocess.env.VITEST_VSCODE
, but that's just a workaround for this problem,NODE_ENV
should still be set totest
just like Vitest does.I wasn't able to figure out the other problem, I keep getting "WebSocket server error: Port is already in use" in my logs and all of my server tests fail through the extension with 404 status instead of the expected one, even though I made sure not to start my server. But I suppose without a repro it's hard to tell what could've gone wrong.
Note
I just realized that the WebSocket issue is most likely due to the
development
value. My server file is creating Vite dev server middleware in that case, which is not intended for tests to run.Reproduction
https://github.com/silvenon/repro/tree/vitest-extension-node-env
For WebSocket I'll file a separate issue.
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: