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

Error loading files #24

Closed
Frikki opened this issue Dec 4, 2014 · 6 comments
Closed

Error loading files #24

Frikki opened this issue Dec 4, 2014 · 6 comments

Comments

@Frikki
Copy link

Frikki commented Dec 4, 2014

Directory structure:

/
|---app
|    \---myapp.js
|---jspm-packages
|---spec
|    \---myapp-spec.js
|---config.js
\---karma.conf.js

In karma.conf.js:

jspm: {
    loadFiles: [ 'spec/**/*-spec.js' ],
    serveFiles: [ 'app/**/*.js' ]
}

When I run karma, files in the app directory are not loaded, as karma prefixes the path with base/. How do I solve this?

@lewisl9029
Copy link

I'm seeing this issue too on v1.1.1.

SystemJS under karma tries to load from /base/jspm_packages/ whereas my actual modules folder is at /www/jspm_packages/ as configured in package.json.

Seems like the SystemJS baseURL for karma-jspm is hard-coded atm: c14be8a

@maxwellpeterson-wf
Copy link
Contributor

All files served by karma's built-in server need to be prefaced with /base as that is where it serves them from. The files being served must at least be included in serveFiles or loadFiles options.

If your jspm_packages are in /www/jspm_packages/ you will need to change your jspm packages configuration to www/jspm_packages/ directory like so:

jspm: {
    packages: "www/jspm_packages/"
}

It will then make a request to /base/www/jspm_packages/ which should resolve correctly.

@lewisl9029
Copy link

Hi,

I do have this set in karma.conf.js:

    jspm: {
      packages: 'www/jspm_packages/',
      loadFiles: [
        'www/**/*-test.unit.js'
      ],
      serveFiles: [
        'www/**/*.js'
      ],
      config: 'www/config.js'
    },

But I still get

WARN [web-server]: 404: /base/jspm_packages/github/angular/bower-angular@1.3.8.js

when I do

import angular from 'angular';

in my test.

As a side note, the test completes properly when I change this from the generated www/config.js:

System.config({
  "paths": {
    ...
    "github:*": "jspm_packages/github/*.js"
  }
});

to

System.config({
  "paths": {
    ...
    "github:*": "www/jspm_packages/github/*.js"
  }
});

But then module loading in my application breaks down.

Looks like my issue has something to do with config.js being placed in a different location from karma.conf.js, and thus using different relative paths (and the jspm.packages config in karma.conf.js doesn't seem to be working?). Doesn't look like this is the case for Frikki though.

@djindjic
Copy link

Hi @lewisl9029,
I've just followed your config and it has help me very much, thanks! I found an solution latest problem, so you can set karma proxies to get it work without changing config.js. Somethink like this:

proxies: {
  '/base/jspm_packages/': '/base/www/jspm_packages/'
}

Also, I want to ask @maxwellpeterson-wf are jspm.packages and jspm.config settings removed? I cant find it in issues but it seems to be true. It sounds so logical for me because package.json already has this configuration.
I'm not an node expert but does it possible to eliminate need for proxies with this package.json config too?

@capaj
Copy link
Contributor

capaj commented Feb 3, 2015

@djindjic that proxy works for you? I have no idea why but I cannot get a proxy to a directory work at all. I always have to spin up another node server running on different port and use it as base. Like this: https://gist.github.com/capaj/8db4533c3a1cab1bf930

Could you post your full karma.conf.js?

@djindjic
Copy link

djindjic commented Feb 3, 2015

You can take a look to my jspm-sample project
I'm very interested to hear your opinion about my workflow if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants