Skip to content

karma run overwrites client.args state #1746

@danielcompton

Description

@danielcompton

Summary

karma run calls this line lib/middleware/runner.js#L50 which overwrites the state of config.client.args with an empty array. This means that plugins that rely on config.client.args will run when calling karma start, but fail after calling karma run once (even when they are subsequently autorun from the karma start process).

Details

I'm using karma-cljs-test to run my ClojureScript tests. It needs a main function to be provided in config.client.args. I was able to run my tests successfully through the auto runner in karma start but when I called karma run, my tests would fail to run as config.client.args had been overwritten with an empty array. Because config is a mutable object, once I had called karma run once, my tests would fail when being rerun by the karma start autorunner.

Commenting out

config.client.args = data.args

let my tests pass, but this is clearly not a viable solution. One option would be to only set config.client.args if data.args is not an empty array.

This also raises the wider question of why a karma run is setting global mutable state. That behaviour was surprising to me, and I don't think it is intentional.

This behaviour seems to have been introduced in ca4c4d8, and relates to 27b8d67, #283, karma-runner/grunt-karma#79, karma-runner/grunt-karma#79, karma-runner/grunt-karma@b658ec9 and karma-runner/grunt-karma@168f7b7.

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