Skip to content

Browser mode: Change the port of browser mode #6677

@sevenc-nanashi

Description

@sevenc-nanashi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions