karma-runner / karma-runner/karma

Should have way of passing variable data from conf to test runner

Open
#1,480 1 comment 0 reactions 0 assignees View on GitHub
discuss
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

There should be a way to share things like dynamic configurations (things that can't be shared via static files) to test runner. Or even configs that are parsed via node.js and normally passed to browser with require.js define() call.

``` js
define('config', { thing1: 'somevalue' });
```

where the content of that object comes from node.js parsing different files to one object (fe. certain pieces of the server configuration that are exposed to clientside etc.).

Would it be possible fe. in `karma.conf.js` to have strings in files array with some special object, as directly having the file content?

``` js
files: [
{ content: "define('config', { thing1: 'somevalue' });" }
]
```

This would not need new fields for passing data and would probably be the most flexible solution.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how karma.conf.js is parsed and how the files array is handled by the test runner. Determine how dynamically generated content could be represented alongside file paths, then define tests showing that an object with content is injected and that existing static file entries continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.