[英]Mocha: TypeError: Converting circular structure to JSON
Mocha suddenly is throwing摩卡突然在扔
TypeError: Converting circular structure to JSON类型错误:将循环结构转换为 JSON
I have done a new setup for executing the test cases.我已经完成了执行测试用例的新设置。 The test cases were running fine till yesterday.直到昨天,测试用例都运行良好。 I am using: Mocha, Chai, Sinon, Enzyme我正在使用:摩卡、柴、诗浓、酶
This is my package.json:这是我的 package.json:
{
"name": "abc",
"version": "1.0.0",
"description": "desc",
"scripts": {
"build": "webpack --config webpack-client.config.js",
"devbuild": "webpack --config webpack-client-dev.config.js",
"test": "mocha --compilers js:babel-register --require ./test/dom.js --require ./test/helpers.js --recursive",
"tdd": "npm test -- --watch",
"coverage": "nyc --reporter=html --reporter=text npm test"
},
"repository": {
"type": "git",
"url": ""
},
"author": "author",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-preset-es2015": "^6.24.1",
"chai": "^4.0.2",
"compression-webpack-plugin": "^0.3.2",
"coveralls": "^2.13.1",
"enzyme": "^2.9.0",
"istanbul": "^0.4.5",
"jquery": "^3.2.1",
"jsdom": "11.0.0",
"jsdom-global": "3.0.2",
"mocha": "3.2.0",
"nyc": "^11.0.3",
"react-addons-test-utils": "^15.6.0",
"sinon": "^2.3.5",
"webpack": "^1.12.2",
"webpack-bundle-analyzer": "^2.3.1"
},
"dependencies": {
"exenv": "^1.2.1",
"expose-loader": "^0.7.0",
"flux": "2.0.1",
"html-webpack-plugin": "^2.28.0",
"htmlescape": "1.0.0",
"intl": "^1.2.5",
"intl-locales-supported": "^1.0.0",
"keymirror": "^0.1.1",
"morgan": "1.5.2",
"object-assign": "^4.1.1",
"prop-types": "^15.5.4",
"react": "^15.4.2",
"react-bootstrap": "^0.31.0",
"react-dom": "^15.4.2",
"react-intl": "^2.0.0-beta-2",
"react-toastr": "^2.8.2",
"zxcvbn": "^4.4.2"
}
}
Please find the error thrown on the console:请找出控制台抛出的错误: Please help.请帮忙。 Thank you谢谢
I ran into this.我遇到了这个。 Based on googling around, there seem to be many different causes for this.根据谷歌搜索,这似乎有很多不同的原因。 Here's my situation: I'm using mocha
with chai
and ts-node/register
to run TypeScript test files directly (without needing to transpile them myself).这是我的情况:我使用带有chai
和ts-node/register
的mocha
来直接运行 TypeScript 测试文件(不需要自己转译它们)。
My solution was this:我的解决方案是这样的:
Add import {describe, it} from 'mocha';
添加import {describe, it} from 'mocha';
at the top of my TS test files.在我的 TS 测试文件的顶部。
I've never had to do this before and I have no idea why I suddenly need to add them now.我以前从来没有这样做过,我不知道为什么我现在突然需要添加它们。 But it is what it is.但是它就是这样啊。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.