Skip to content

Custom commands shifts arguments when any value is undefined #10864

Description

@AriPerkkio

Describe the bug

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    browser: {
      commands: {
        readConfig(encoding: undefined | string, filepath: string) {
          // ...
        }
      },
    }
  },
});
import { commands } from "vitest/browser";

// On server side: { encoding: "utf8", filepath: "file.ts" } ✅
commands.readConfig("utf8", "file.ts");

// On server side: { encoding: "file.ts", filepath: undefined } ❌
commands.readConfig(undefined, "file.ts");

// Work-around for now:
const encodig: string | undefined = ...
commands.readConfig(encoding ?? null, "file.ts");

Reproduction

#10865

System Info

Vitest CI, Playwright provider, Vitest 4.1 + 5

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runner

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions