Skip to content

Allow Angular to pass no browsers to Karma #26537

Closed
@Nvveen

Description

@Nvveen

Command

test

Description

Karma has a CLI option --no-browsers to allow Karma to open without any connected browsers. This can be achieved in Angular by passing an empty [] array in karma,conf.js. This is useful when running the dev server in a devcontainer, where no display server and instances of browsers are installed. Manually opening a browser with the ports forwarded then runs the tests like normal.
The issue starts when using the built-in Karma config, but passing either "browsers": "", or the CLI flag "--browsers=\"" to ng test. The line at

checks if the browsers option exists, but since the string is empty, the expression is false and the default Karma option of ['Chrome'] is instead used.

Describe the solution you'd like

Changing this line to if (options.browsers != null) and filtering the split array by non-empty strings should solve this particular issue.

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions