karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

Feature Request: Add way to preload assets in karma config. #3485

Open darrnshn opened 4 years ago

darrnshn commented 4 years ago

Karma config allows you to specify included=true to let karma include the asset for you. It would be great if karma also allowed you to optionally specify that the include should have the preload attribute.

devoto13 commented 4 years ago

Please describe the problem, which this feature would resolve?

darrnshn commented 4 years ago

We have some assets that we would like to include in our test HTML page. We need to set the preload attribute on those includes. Because of this, we cannot use Karma config to include these assets automatically anymore, we have to manually inject the assets into the test page via JS.

devoto13 commented 4 years ago

Can you provide an example? Are we talking about rel="preload"? AFAICT it is a purely performance thing and should not prevent you from including assets? Or am I missing something?

You can also use type="dom" in files configuration to include arbitrary content into the test page.

darrnshn commented 4 years ago

Thanks, yes I was referring to rel="preload". It should be a pure performance thing.

We can use type="dom" for a workaround.