computmaxer / karma-jspm

Other
74 stars 52 forks source link

File not found (404) with the 0.17 beta 29 of JSPM #179

Closed lmaze closed 7 years ago

lmaze commented 7 years ago

Hi there !

I try to run karma-jspm with the latest 0.17 version of JSPM (0.17 beta 29) but it does not seem to work. Everything seems to work well but Karma did not find my files. When I remove the karma-jspm plugin everything works...

I have the following error :

> karma start karma.conf.js

10 10 2016 17:48:36.281:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
10 10 2016 17:48:36.285:INFO [launcher]: Launching browser Chrome with unlimited concurrency
10 10 2016 17:48:36.305:INFO [launcher]: Starting browser Chrome
10 10 2016 17:48:37.289:INFO [Chrome 53.0.2785 (Windows 10 0.0.0)]: Connected on socket /#Gr7_DzNJAamu4P3jAAAA with id 88951264
Chrome 53.0.2785 (Windows 10 0.0.0) DEBUG: 'default-adapter.js running'

10 10 2016 17:48:37.589:WARN [web-server]: 404: /test/tu/specs/test.specs
Chrome 53.0.2785 (Windows 10 0.0.0) DEBUG: 'karma.loaded'
Chrome 53.0.2785 (Windows 10 0.0.0) DEBUG: 'Load prerequisite files.'
Chrome 53.0.2785 (Windows 10 0.0.0) DEBUG: 'Loading application and test files'
Chrome 53.0.2785 (Windows 10 0.0.0) DEBUG: 'KARMA ERROR ', Error{originalErr: Error{}}
Chrome 53.0.2785 (Windows 10 0.0.0) ERROR
  Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:9876/test/tu/specs/test.specs
        Error: XHR error (404 Not Found) loading http://localhost:9876/test/tu/specs/test.specs
        Error loading http://localhost:9876/test/tu/specs/test.specs

I have a very simple configuration just for testing. Here is my configuration file for Karma :

module.exports = function(config) {
  config.set({
    basePath: './',
    frameworks: ['jspm', 'jasmine'],
    jspm: {
      config: "jspm.config.js",
      browser: "jspm.browser.js",
      packages: "lib/jspm/",
      loadFiles: [
        'test/tu/specs/*.specs.js'
      ]
    },
    plugins:[
      'karma-jasmine',
      'karma-uiuxengineering-jspm',
      'karma-chrome-launcher'
    ],
    exclude: [
    ],
    preprocessors: {
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: false,
    browsers: ['Chrome'],
    singleRun: true,
    concurrency: Infinity
  })
}

I have a standard JSPM configuration. The only difference is the installation directory of my packages ("lib/jspm" here). My specs files is in the "test/tu/specs" directory.

Does the plugin works well with the 0.17 version of JSPM?

crtormen commented 7 years ago

Have you tried to add a proxy to your test folder? Try to put this

proxies: {
    '/test/': '/base/test/',
}

in your karma.conf.js

If it pass, but you keep getting 404 error from some jspm_packages file, try to add a proxy entry to jspm_packages too, with /base before your path.

And if not work, try to add that changing your baseUrl to baseUrl = "", or baseUrl="."

lmaze commented 7 years ago

Thank you very much for your answer. In fact it works well with proxies, sorry for not having better understood how Karma worked.

I have also found a seed example (https://github.com/UIUXEngineering/angular2-jspm-typescript-seed) which was very helpful and allowed me to set up a configuration that works.

My 404 problem seemed still combined with what looks like a bug on browserConfig property. I created another bug about it ;)