Karma proxies are not working

风格不统一 提交于 2019-12-05 18:48:56

Try:

proxies: {
  '/app/': '/base/app/',
  '/jspm_packages/': '/base/jspm_packages/'
}
LazerBass

If you have configured your jspm-config with a baseUrl of "/", try removing the baseUrl entry since karma-jspm does not support a custom baseUrl. Then you should be able to get rid of the "proxies" entry for the jspm_packages.

See: https://github.com/Workiva/karma-jspm/issues/91

After having done lot of trial and error, found out the following way:

Instead of playing with proxies, alter the jspm paths config in karma.config.js

jspm: {
       ...
        paths: {
            "github:*": "app/jspm_packages/github/*",
            "npm:*": "app/jspm_packages/npm/*",
            'app/*': 'app/*.js'
        },

        ...
    },

What finally did the trick for me (karma, babel, JSPM/SystemJS) was to have this:

Remove baseUrl from the karma.conf.js and have this jspm section:

 jspm: {
        config: 'config.js',
        loadFiles: [
            'www/**/*.spec.js'
        ],
        serveFiles: [
            'www/**/!(*spec).js'
        ],
        paths: {
            "github:*": "/base/jspm_packages/github/*",
            "npm:*": "/base/jspm_packages/npm/*",
            'www/*': '/base/www/*'
        }
    },
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!