question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There should be a way to ask karma to serve a specific directory in a given path

See original GitHub issue

There should be a way to specify karma that a specific content should be served from a specified path. Right now, the only (very hacky) way to do this is

files = [
  {pattern: 'images/*.png', included: false, served: true}
];

proxies =  {
  '/images': 'http://localhost:9876/base/images'
};

That has the big issue that, when the configuration is run, we cannot be positive that karma will run at port 9876 or another port

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
silvawcommented, May 24, 2018

None of those answers solved this annoying 404 warn.

I’ve this setup in my karma.conf.js:

files: [
    {pattern: 'src/main/webapp/assets/images/**/*.png', included: false, served: true},
    'src/main/webapp/assets/scripts/vendor/*.js',
    'src/main/webapp/assets/scripts/dist/*.js',
    'src/main/webapp/assets/bower_components/angular-mocks/angular-mocks.js',
    'src/main/webapp/assets/partials/**/*.html',
    'src/test/javascript/spec_helper.js',
    'src/test/javascript/**/*.js',
],
exclude: [],
.
.
.
proxies: {
    '/assets/images/diagnostico-assinador/': '/base/',
    '/assets/images/prioridade/': '/base/'
}

with proxies setup I got this warn:

WARN [web-server]: 404: /base/image.png

without proxies setup I got this warn:

WARN [web-server]: 404: /assets/images/diagnostico-assinador/image.png
WARN [web-server]: 404: /assets/images/prioridade/image.png
2reactions
vojtajinacommented, Jan 30, 2014

@glepretre I think I like your suggestion the best, this should work:

proxies: {
  '/img/': '/base/app/img/'
},

We just need to fix https://github.com/karma-runner/karma/blob/master/lib/middleware/proxy.js#L37-L42 - if no host/port is defined, use the Karma ones (proxy to Karma itself). Anybody willing to send a PR for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

karma config moving a file to base directory - Stack Overflow
Karma does this because there's no simple way to provide a path to these files through the usual /base/ path that is both...
Read more >
Configuration options | karma
Karma will be performing authentication using configured list of username & password pairs. This method is only recommended for testing. External authentication ...
Read more >
Configuration File - Karma
The easiest way to generate an initial configuration file is by using the karma init command. This page lists all of the available...
Read more >
Testing - Angular
The Angular CLI takes care of Jasmine and Karma configuration for you. It constructs the full configuration in memory, based on options specified...
Read more >
Front-End Unit Testing Using Karma Test Runner
#1) basePath: This configuration bears the name of any folder which should be used to resolve the path information provided for test and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found