Closed vollmerr closed 1 year ago
I'm having the same problem.
Same issue here!! We are blocked from upgrading because of this.
Same here !
Same here after upgrading from 0.34.2
to 0.34.3
. We noticed that our CI pipelines kept failing because vitest always tries to open the browser (even tho the CI
env variable is set). It also opens the browser every time on my local machine, despite setting various options to disable it.
I'm wondering if this problem is limited to Windows. i'm using macos and it doesn't happen.
I'm using Windows; though, when I run this though a pipeline, the same error happens because it tries to open a browser during the pipeline run. We use RedHat Linux images.
Chiming in that this impacts me locally on MacOS as well as CI running Linux.
Downgrading to either 0.34.2
or 0.33.0
solved the problem.
Here's a portion of my vite.config.ts
. If I comment out server.open
then vitest
will not open a browser window.
Something tells me vitest shouldn't be reading the server
portion of the config, should it?
... snip ...
server: {
proxy: {
"^/api": {
target: "http://localhost:8080",
changeOrigin: false,
secure: false,
},
},
strictPort: true,
open: "http://localhost:8080", // <- if I comment it out, then a window isn't opened on 0.34.3
},
test: {
globals: true,
environment: "jsdom",
coverage: {
reporter: ["text", "html"],
exclude: [
"node_modules/",
],
},
},
... snip ...
@fh-igor-serko thank you for investigating:
so a quick-and-dirty-fix for the old behaviour is:
//in vite.config.js
...
server: {
port: 8080,
open: process.env.NODE_ENV === 'test' ? false : true,
...
},
test: {
...
}
or in your case
open: process.env.NODE_ENV === 'test' ? false : 'http://localhost:8080',
Thanks, guys, I was able to successfully reproduce the issue, and I'm currently working on a solution. I'll be submitting a PR to fix the issue soon
Describe the bug
After upgrading from vitest
^0.33.0
to^0.34.3
when running any tests the dev server now opens, and in that dev server that is opened it fails to load the files.Have tried setting the vite config to have test.open to false but still opens (which shows as default of true in the typedef file but false in https://vitest.dev/config/#open)
Reproduction
https://codesandbox.io/p/sandbox/gallant-ptolemy-fjnjwr
System Info
Used Package Manager
yarn
Validations