Skip to content

GUI tests fail locally on Windows due to pathing and execution bugs #3067

@kartik-py12

Description

@kartik-py12

Problem

Running cargo test --test gui fails completely on Windows machines. I dug into tests/gui/runner.rs and found three distinct Windows-specific issues preventing the headless browser tests from running:

1. npm and npx commands not found
Rust's Command::new("npm") fails on Windows because the executables are actually batch files (npm.cmd).

2. Drive letters break the version parser
The parser does l.split(':').nth(1) expecting the version after the first :. However, Windows paths have a drive letter (e.g., V:\), so nth(1) returns the path segment instead of the version. This causes the browser-ui-test version check to panic with "not installed".

3. Backslash separators break DOC_PATH in redirect tests
out_dir.display() on Windows returns backslashes (V:\coding\...). The headless browser receives file://V:\coding\... but reports file:///V:/coding/... — causing redirect.goml to fail on every run due to a string mismatch.

Expected Behavior
Running cargo test --test gui should execute the test suite locally on Windows machines without panicking on OS-specific pathing or command formatting.

Steps

  1. On a Windows machine with Rust and Node/npm installed, clone the repository.
  2. Run npm install in the root directory.
  3. Run cargo test --test gui.
  4. Result: Immediate panic on npm command not found. (If patched manually, it subsequently panics on the version parser, and then fails the redirect test).

Possible Solution(s)

1. Add a helper for Windows .cmd resolution:

fn npm_cmd(name: &str) -> Command {
    if cfg!(windows) {
        let mut cmd = Command::new("cmd");
        cmd.args(["/C", &format!("{}.cmd", name)]);
        cmd
    } else {
        Command::new(name)
    }
}

Use npm_cmd("npm") and npm_cmd("npx") in place of
Command::new("npm") / Command::new("npx").

2. Fix drive letter breaking version parse:

Change nth(1) to last() so it grabs the version string
regardless of drive letters.

l.split(':').last()?.strip_prefix("browser-ui-test@")

3. Fix path separators in DOC_PATH:

Normalize slashes before formatting the file URI.

let out_dir_str = out_dir.display().to_string().replace('\\', "/");
let mut doc_path = format!("file:///{}", out_dir_str);

Notes

  • Environment: Windows 11, PowerShell, Rust stable (msvc), Node 24, npm 10.
  • Willingness to contribute: I have all three fixes working locally. All 19 GUI tests pass flawlessly on my Windows machine after applying these changes. I am happy to submit a PR if this is something the team would like addressed!

Version

0.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: A bug, incorrect or unintended behavior

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions