javascript - 在 Coffeescript : JSON. stringify 循环结构序列化中使用 karma 时出错

标签 javascript testing coffeescript karma-runner

为什么我在使用 Coffeescript 运行 karma 时会出现此错误?

$ karma run
WARN [watcher]: Pattern "/home/yang/reactive.coffee/test/mock/**/*.js"
does not match any file.
WARN [watcher]: Pattern "/home/yang/reactive.coffee/src/**/*.js" does
not match any file.
PhantomJS 1.9 (Linux) ERROR
        TypeError: JSON.stringify cannot serialize cyclic structures.
        at http://localhost:8080/socket.io/socket.io.js:1066
PhantomJS 1.9 (Linux): Executed 0 of 0 ERROR (0.212 secs / 0 secs)
PhantomJS 1.9 (Linux) ERROR
        TypeError: JSON.stringify cannot serialize cyclic structures.
        at http://localhost:8080/socket.io/socket.io.js:1066
PhantomJS 1.9 (Linux): Executed 0 of 0 ERROR (0.212 secs / 0 secs)

当我切换到 Firefox 时也会发生这种情况:

Firefox 20.0 (Linux) ERROR
        TypeError: cyclic object value
        at http://localhost:8081/socket.io/socket.io.js:1066

当我从 CS 切换到 JS 时,错误消失了。

更多详细信息 - 如果我可以提供任何其他帮助,请告诉我:

$ karma --version
Karma version: 0.8.5

$ tree src
src
└── reactive.coffee

0 directories, 1 file

$ tree test
test
└── spec
    └── test_reactive.js

1 directory, 1 file

$ cat karma.conf.js
// Karma configuration

// base path, that will be used to resolve files and exclude
basePath = '';

// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  'src/*.coffee',
  'src/**/*.js',
  'test/mock/**/*.js',
  'test/spec/**/*.js'
];

// list of files to exclude
exclude = [];

// test results reporter to use
// possible values: dots || progress || growl
reporters = ['progress'];

// web server port
port = 8080;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO
|| LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['PhantomJS'];

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 10000;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;

最佳答案

虽然我不确定为什么 CS 会导致这种情况而 JS 不会,但请尝试使用 SO here 上提供的解决方案.

关于javascript - 在 Coffeescript : JSON. stringify 循环结构序列化中使用 karma 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16555108/

相关文章:

javascript - 根据哈希 url 参数在页面加载时加载内容

python - 运行测试时找不到 Django 中已安装的应用程序

unit-testing - unitTest中如何使用EasyMock

c# - 单元测试异步操作

exit - 如何退出CoffeeScript REPL?

javascript - 开放层 3 : How to change/set the style of vector map

javascript - 如何将总纳秒转换为 HH :MM:SS:ms:ns in JavaScript and node? 格式的字符串

javascript - 如何在点击时为 translateX() 设置动画

javascript - 将 cheerio 对象转换为字符串

ruby-on-rails - 主干和 rails 。为什么要在 Backbone 中设置路由?