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
- 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.
- 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.
ui/src/lib/__tests__/runtime-env.test.tsrunsdocker/env.sh, the script the images use to generateenv.jsat startup, throughexecFileSync("sh", [script], ...). On Windows without anshon thePATH,npm testinui/fails:writes valid JavaScript carrying the settingsanddefaults to no OIDC and no local login formfail withspawnSync sh ENOENT.fails rather than serving no configuration when it cannot writepasses for the wrong reason: it expectsexecFileSyncto throw, and the missingshthrows too, so the test says nothing about the script on Windows.Reported by a contributor in #27 (168/170 passing on Windows).
Proposed fix
describe.skipIf(...)after checkingspawnSync("sh", ["-c", "true"])for anENOENTerror. The script only runs inside Linux images, so there is nothing to test withoutsh.error.status), not a spawn error (error.code === "ENOENT").Done when
npm testinui/passes on Windows without Git Bash, with this suite reported as skipped.