Skip to content
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

Browser mode: Change the port of browser mode #6677

Closed
4 tasks done
sevenc-nanashi opened this issue Oct 10, 2024 · 4 comments
Closed
4 tasks done

Browser mode: Change the port of browser mode #6677

sevenc-nanashi opened this issue Oct 10, 2024 · 4 comments

Comments

@sevenc-nanashi
Copy link

sevenc-nanashi commented Oct 10, 2024

Clear and concise description of the problem

I'd like to change the port of browser mode, in order to run multiple browser tests in a workspace (One for storybook, one for unit tests).
I tried to specify the server.port, but it's merged and gone here:

server: {
hmr: false,
watch: null,
},

It would be nice to have ability to change the port number.

Suggested solution

  • Recognize server.port in the argument of defineWorkspace.
  • Create test.browser.serverPort option.

Alternative

None, I guess

Additional context

For anyone want to change port now (workaround):

// Vitest doesn't recognize server.port, so we modify it using a plugin
// ref: https://github.com/vitest-dev/vitest/issues/6677
const portChangerPlugin = (port: number): Plugin => ({
  name: "port-changer",
  config() {
    return {
      server: {
        port,
      },
    };
  },
});

Validations

@sheremet-va
Copy link
Member

You should use test.browser.api

export default defineConfig({
  test: {
    browser: {
      api: 12345,
    }
  }
})

@sevenc-nanashi
Copy link
Author

Oh, thanks! (I thought that it was different because its default is not 5173)

@sevenc-nanashi sevenc-nanashi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
@sheremet-va
Copy link
Member

It is still a bug because user's port should be respected if it's set

@sheremet-va
Copy link
Member

Actually, it is not a bug. We assign a different port to not clash with the dev server. I will update the documentation to mention this.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants