gpt4 book ai didi

javascript - karma : Move Folder -> Missing Error Handler on Socket?

转载 作者:太空狗 更新时间:2023-10-29 19:35:45 25 4
gpt4 key购买 nike

对于由 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.jskarma.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 }
]

最佳答案

引用您的项目 https://github.com/oliver-spryn/portfolio

您可以尝试更改您的 karma-test-shim.js。在 System.config 下,将格式:'register' 更改为格式:'cjs'。

我复制了你的 karma.conf.js + karma-test-shim.js 并创建了简单的 proj 来模拟你遇到的问题(按照上面的修复)。 https://github.com/phhoangbao/angular2-test

关于javascript - karma : Move Folder -> Missing Error Handler on Socket?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35952704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com