karma-runner / karma-runner/karma
Absolute URL files always included
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
I'm using Karma 0.13.15.
When I use absolute URLs, like below, they are always "included":
```
# my karma.coffee
{ pattern: 'http://localhost:3020/assets/angularAMD/angularAMD.min.js', included: false },
```
I see that this is by design. In `karma/lib/config.js`, there's this:
```
var UrlPattern = function (url) {
Pattern.call(this, url, false, true, false, false)
}
```
It's forcing served, included, watched, and nocache.
However, this isn't mentioned [in the documentation](https://karma-runner.github.io/0.13/config/files.html).
The problem with always including files, aside from the surprise of Karma ignoring my options without warning me, is that I assumed it wasn't doing that. So when I got RequireJS errors of:
```
Error: Mismatched anonymous define() module: function () {"use strict";function...
```
... I didn't have any idea of what could causing that. In my project, I had a single `script` tag which loads `main.js`, which then loads the rest of the my app, which is the standard way to do it in RequireJS. I thought there should be no way I should be getting such errors, because I don't have anonymous defines anywhere.
**So, can you please mention that in the documention?** Better yet, if you warn that you are ignoring all the options (`served`, `included`, `watched`, `nocache`) at run time when an absolute URL is used, that would make it very clear.
As a tip to someone not on the karma team reading this, I offer this advice. Initially I was using PhantomJS. However, by using Chrome, I was able to use its awesome DevTools and see the files actually loaded by Karma, which includes `context.html` that is loaded in the iframe, and there you're able to see which files are actually included.
Contributor guide
Research direction
Start with the files configuration documentation linked in the issue and compare it with the absolute-URL handling shown in karma/lib/config.js. Document that absolute URLs force served, included, watched, and nocache, so the page clearly explains the resulting behavior and the change is complete when the published guidance covers those options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100