Skip to content

fix: make npm test portable to Windows - #99

Open
Wuodan wants to merge 1 commit into
bats-core:mainfrom
bats-hardened:upstream-PR/04-make-npm-test-portable-to-Windows
Open

Wuodan wants to merge 1 commit into
bats-core:mainfrom
bats-hardened:upstream-PR/04-make-npm-test-portable-to-Windows

Conversation

@Wuodan

@Wuodan Wuodan commented Sep 11, 2026

Copy link
Copy Markdown

On Windows, the test command runs through two shell layers:

GitHub Actions (PowerShell)
-> npm cit
-> npm test (cmd.exe)
-> bats ${CI+-t} test

cmd.exe does not understand the POSIX ${CI+-t} expansion. It passes the expression to Bats as an argument, which Bats interprets as a test path and fails before running any tests.

The expansion was added in 2019 to select TAP output in CI, but Bats has done that automatically when CI is set since 2014. Remove the redundant expansion so npm test works across platforms without changing CI output.

This is related to PR 15 in bats-core/.github

On Windows, the test command runs through two shell layers:

GitHub Actions (PowerShell)
  -> npm cit
    -> npm test (cmd.exe)
      -> bats ${CI+-t} test

cmd.exe does not understand the POSIX ${CI+-t} expansion. It passes the expression to Bats as an argument, which Bats interprets as a test path and fails before running any tests.

The expansion was added in 2019 to select TAP output in CI, but Bats has done that automatically when CI is set since 2014. Remove the redundant expansion so npm test works across platforms without changing CI output.
@Wuodan

Wuodan commented Sep 18, 2026

Copy link
Copy Markdown
Author

Also related to PR 1258 fixing BATS_LIB_PATH on Windows in bats-core

Without it, this
BATS_LIB_PATH=$PWD/node_modules:${BATS_LIB_PATH-}
in

BATS_LIB_PATH=$PWD/node_modules:${BATS_LIB_PATH-}
will fail on Windows runners.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant