computmaxer / karma-jspm

Other
74 stars 52 forks source link

404 Error #189

Closed JSlain closed 6 years ago

JSlain commented 6 years ago

We're trying to use RxJS in a javascript application. It works pretty well at rutime, but our tests fails with the following error:

16 11 2017 15:02:26.012:WARN [web-server]: 404: /base/process.js
Chrome 61.0.3163 (Windows 10 0.0.0) ERROR
  Error: (SystemJS) XHR error (404 Not Found) loading process.js
        Error: XHR error (404 Not Found) loading process.js
        Error loading process.js as "process" from src/jspm_packages/npm/rxjs@5.5.2/Rx.js

Here's my karma configuration (jspm section)

        jspm: {
            loadFiles: [
                {pattern: 'src/app/**/*.spec.*', nocache: true},
                {pattern: 'src/jspm_packages/system-polyfills.js', nocache: true}
                ],

            serveFiles: [
                'src/app/**/*!(.spec).js',
                'src/app/**/*.!(js)'],

            paths: {
                'github:*': 'src/jspm_packages/github/*',
                'npm:*': 'src/jspm_packages/npm/*',
                'app/*': 'src/app/*'
            },

            cachePackages: false

        },

Something strange is that every other package get loaded well. For example: http://localhost:12505/base/src/jspm_packages/npm/rxjs@5.5.2/Rx.js

In the case of process.js, here's the url trying to be resolved: http://localhost:12505/base/process.js

It doesn't make any sense, this is not the pas supposed to be searched at all. Even my config.js shows it should look somewhere else.

    "npm:rxjs@5.5.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.1",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "symbol-observable": "npm:symbol-observable@1.0.4"
    },
SerkanSipahi commented 6 years ago

@JSlain could you share a test repo that reproduce the issue, thank you.

JSlain commented 6 years ago

Sure, here it is:

https://github.com/JSlain/karma-jspm-189

Maybe it's the way i configured the karma plugin. We're using this setup for a year without problems...

JSlain commented 6 years ago

Found out.

Karma configuration:

basePath: './src',

...

    jspm: {
        // Edit this to your needs
        loadFiles: [
            'jspm_packages/system-polyfills.js',
            {pattern: '**/*.spec.*', nocache: true}],

        cachePackages: false
    },

Much more simpler!

SerkanSipahi commented 6 years ago

@JSlain nice :)

martynchamberlin commented 6 years ago

I too was getting this error, and confirmed that this fixed the error. I can't help but wonder if we should consider adding this advice to the core README documentation?

basePath: './src',