业力代理不起作用

时间:2015-09-07 09:01:01

标签: proxy karma-runner jspm

我使用 Karma(v0.12.37)作为测试运行器以及 JSPM(v0.16.2)。我在karma中添加了以下代理配置,以便允许正确加载JSPM文件:

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

这不能解决问题,因此无效:

PhantomJS 2.0.0 (Windows 8 0.0.0) ERROR: 'Potentially unhandled rejection [10] Error: XHR error loading http://localhost:9876/base/jspm_packages/npm/babel-core@5.8.22.js
        Error loading http://localhost:9876/base/jspm_packages/npm/babel-core@5.8.22.js
        Error loading http://localhost:9876/base/app/pages/examples/todo-example/todo.controller.test.js'

调试日志正在提供:

proxying request - /base/jspm_packages/npm/babel-core@5.8.22.js to localhost:9876
/base/app/jspm_packages/npm/babel-core@5.8.22.js { host: 'localhost',
  port: 9876,
  baseProxyUrl: '/base/app/jspm_packages/',
  https: false }

但是下面包含'app'的网址正常运行:

http:// localhost:9876 / base / app / jspm_packages/npm/babel-core@5.8.22.js

关于出了什么问题的任何线索?

4 个答案:

答案 0 :(得分:5)

尝试:

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

答案 1 :(得分:2)

如果您已使用baseUrl“/”配置了jspm-config,请尝试删除baseUrl条目,因为karma-jspm不支持自定义baseUrl。然后你应该能够摆脱jspm_packages的“代理”条目。

请参阅:https://github.com/Workiva/karma-jspm/issues/91

答案 2 :(得分:0)

经过大量的反复试验后,发现了以下方式:

不要使用代理,而是更改<!DOCTYPE html> <html> <head runat="server"> <title></title> <link rel="stylesheet" href="styling/stylinghoved.css" type="text/css" /> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> <style type="text/css"> .auto-style1 { width: 94%; } </style> </head> <body> <form id="form1" runat="server"> <div> <div id="siden"> <div id="top"> <table id="toptable"> <tr> <td rowspan="2" id="toptablemilto" class="auto-style1"> Milto </td> <td style="margin:auto"> login // kurv </td> </tr> <tr> <td> søg:&nbsp; <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </td> </tr> </table> </div> <div id="links"> <ul id="lin"> <li><asp:HyperLink ID="HyperLink1" runat="server">LK Produkter</asp:HyperLink></li> <li><asp:HyperLink ID="HyperLink2" runat="server">Flash Light</asp:HyperLink></li> <li><asp:HyperLink ID="HyperLink3" runat="server">Philips</asp:HyperLink></li> <li><asp:HyperLink ID="HyperLink4" runat="server">HyperLink</asp:HyperLink></li> </ul> </div> <div id="indhold"> <asp:ContentPlaceHolder id="hovedsideplaceholder" runat="server"> </asp:ContentPlaceHolder> </div> <div id="bund">bund</div> </div> </div> </form> </body> </html>

中的jspm paths配置
karma.config.js

答案 3 :(得分:0)

对我来说最终的伎俩(业力,babel,JSPM / SystemJS)是这样的:

从karma.conf.js中删除baseUrl并拥有此jspm部分:

 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/*'
        }
    },