Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of the "base" directory #1607

tkrotoff opened this issue Oct 5, 2015 · 7 comments

Get rid of the "base" directory #1607

tkrotoff opened this issue Oct 5, 2015 · 7 comments


Copy link

@tkrotoff tkrotoff commented Oct 5, 2015

Following a question I've asked (without success) on the mailing-list few months ago: Why a directory named "base" is prepended to all the loaded files?

With Karma all files are inside a directory named "base". I don't see the need for this added complexity.


In comparison, when using Jasmine directly (gulp-jasmine-browser or by writing my own SpecRunner.html), there is no "indirection": all files are loaded from the root directory => much easier, the way it should be.


  • I have to prepend "base" to my XHRs for them to work (or add "urlRoot: 'base'" to karma.conf.js => does not work anymore). I'm not the only one in this case:
  • This makes it difficult to run unit tests using both Karma and (original) Jasmine.
  • Also source maps don't work (I use TypeScript) when debugging my tests using Karma singleRun: true.
    In Chrome when I click on a .ts file, I get a 404 because Karma tries to fetch /base/Hello.spec.ts instead of /Hello.spec.ts.
Copy link

@ghost ghost commented Oct 22, 2015

+1, base is making things hard, especially interoperability with different test systems.

Copy link

@victor-xiong victor-xiong commented Nov 12, 2015

+1, html page setup with karma 'base' will not be able to be open correctly by other web servers.

Copy link

@jcrben jcrben commented Nov 15, 2015

If nothing else, we should figure out what advantages (if any) the base prefix provides.

Copy link

@jeremyroberts0 jeremyroberts0 commented Dec 31, 2015

+1, this is a regular source of annoyance in XHR paths.

Copy link

@jamesdanged jamesdanged commented Jul 12, 2017

Seems there is now an easy way to deal with this by using the "proxies" setting. See >> Loading Assets.

Copy link

@franktopel franktopel commented Nov 19, 2019

@jamesdanged Can you show an example of how to address this problem using the proxies setting?

Copy link

@Krinkle Krinkle commented Nov 21, 2020


  • Let Karma start two servers. One for serving the base directory and client start HTML (e.g. localhost:9876), and another for its own files and web sockets (e.g. localhost:9842).
  • The base server is essentially a plain static file server with / relating to the base directory (e.g. root of your git project). The server would have one "virtual" path, e.g. "/" itself from which it serves the client HTML that kicks off the test. We may want to make this virutal path configurable, so that e.g. one could instruct it to open at /test/karma.html, for even better compatibility with a real HTML one might have at /test/qunit.html in that same directory - ensuring that any relative URLs are resolved the same way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.