Skip to content

runtime-env tests fail on Windows without sh, and one passes for the wrong reason #28

Description

@ndreno

ui/src/lib/__tests__/runtime-env.test.ts runs docker/env.sh, the script the images use to generate env.js at startup, through execFileSync("sh", [script], ...). On Windows without an sh on the PATH, npm test in ui/ fails:

  • writes valid JavaScript carrying the settings and defaults to no OIDC and no local login form fail with spawnSync sh ENOENT.
  • fails rather than serving no configuration when it cannot write passes for the wrong reason: it expects execFileSync to throw, and the missing sh throws too, so the test says nothing about the script on Windows.

Reported by a contributor in #27 (168/170 passing on Windows).

Proposed fix

  1. Skip the suite when no POSIX shell is available, for example with describe.skipIf(...) after checking spawnSync("sh", ["-c", "true"]) for an ENOENT error. The script only runs inside Linux images, so there is nothing to test without sh.
  2. In the failure test, assert that the script itself failed: a non-zero exit status (error.status), not a spawn error (error.code === "ENOENT").

Done when

  • npm test in ui/ passes on Windows without Git Bash, with this suite reported as skipped.
  • On Linux and macOS the three tests still run, and the failure test fails if the script is changed to exit 0 when it cannot write.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersjavascriptPull requests that update javascript code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions