【发布时间】:2016-06-27 10:26:38
【问题描述】:
我有一组有效的单元测试,用于由 Karma 0.13.22 运行的 Angular 2.0 项目,使用 Socket.io 1.4.5 连接到 Chrome 48 浏览器。我在此配置下进行测试,结果有效:
app/
tests/app
karma-test-shim.js
karma.conf.js
然后,在不更改任何代码的情况下,我移动了一个文件夹:
source/app/
tests/app
karma-test-shim.js
karma.conf.js
...然后我用新路径更新了karma-test-shim.js 和karma.conf.js。
现在测试甚至没有运行,我得到了这个错误:
Missing error handler on `socket`.
TypeError: (msg || "").replace is not a function
at /home/spryno724/projects/portfolio/node_modules/karma/lib/reporter.js:45:23
at onBrowserError (/home/spryno724/projects/portfolio/node_modules/karma/lib/reporters/base.js:58:60)
... more stack trace ...
11 03 2016 20:24:11.038:WARN [Chrome 48.0.2564 (Windows 10 0.0.0)]: Disconnected (1 times)
知道是什么原因造成的吗? 唯一改变的是文件夹路径。
来自karma.conf.js的样本:
files: [
// Load Angular 2 dependencies and the SystemJS shim
{ pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true },
{ pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true },
{ pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/angular2.dev.js', included: true, watched: true },
{ pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true },
{ pattern: 'karma-test-shim.js', included: true, watched: true },
// The application and test files
{ pattern: 'source/app/**/*.js', included: false, watched: false },
{ pattern: 'test/unit/app/**/*.js', included: false, watched: false },
// Support for debugging sessions
{ pattern: 'source/app/**/*.ts', included: false, watched: false },
{ pattern: 'test/unit/app/**/*.js.map', included: false, watched: false }
]
【问题讨论】:
-
您是否更新了 karma.conf 以查看源/应用程序?
-
@MorganG 是的,我更新了 karma.conf:gist.github.com/oliver-spryn/0baef42e8f18174125c2 这是我做的第一件事。不知道你说的第二个问题是什么意思。
-
我认为这是 Socket.IO 的一个问题,看起来其他人在这个较新版本的 0.13.18 中也遇到了同样的问题。 github.com/karma-runner/karma/issues/1782 虽然不是完全相同的问题,但有人报告说仅在 4 小时前使用套接字再次遇到问题。希望有人能对此给出一个好的答案,因为这很奇怪。
-
这有什么更新吗?我可以 1:1 重现问题,但目前也在寻找解决方案。
-
有人找到解决方案吗?
标签: javascript node.js socket.io angular karma-runner