Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: JSON.stringify cannot serialize cyclic structures #323

Closed
ricazhang opened this issue Apr 4, 2018 · 1 comment
Closed

TypeError: JSON.stringify cannot serialize cyclic structures #323

ricazhang opened this issue Apr 4, 2018 · 1 comment

Comments

@ricazhang
Copy link

ricazhang commented Apr 4, 2018

I'm submitting a bug report

Webpack version:
angular-cli version 1.6.1 which is using webpack ~3.10.0

Webpack Karma version:
see above

Karma version:
2.0.0

Please tell us about your environment:
Windows 7

Browser: PhantomJS 2.1.1
"karma-phantomjs-launcher": "1.0.4"

Current behavior:

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

I'm trying to run karma tests using angular cli and PhantomJS (ng test --code-coverage --single-run) but am getting an error which seems to be causing 24 out of my 33 unit tests to fail. When I run the tests with Chrome as the configured browser, all of the tests pass.

PhantomJS 2.1.1 (Windows 7.0.0) AppService should be created FAILED
    TypeError: JSON.stringify cannot serialize cyclic structures. in http://localhost:9876/_karma_webpack_/polyfills.bundle.js (line 5424)
    stringify@[native code]
    stringify@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:5424:28
    displayModal@http://localhost:9876/_karma_webpack_/scripts.bundle.js:4473:57
    createModalContent@http://localhost:9876/_karma_webpack_/scripts.bundle.js:4453:41
    BMS@http://localhost:9876/_karma_webpack_/scripts.bundle.js:7282:43
    BMSService@http://localhost:9876/_karma_webpack_/main.bundle.js:2095:25930
    _createClass@http://localhost:9876/_karma_webpack_/vendor.bundle.js:84475:34
    _createProviderInstance$1@http://localhost:9876/_karma_webpack_/vendor.bundle.js:84447:38
    resolveNgModuleDep@http://localhost:9876/_karma_webpack_/vendor.bundle.js:84432:42
    _createClass@http://localhost:9876/_karma_webpack_
    ...(there was more in the stack but I cropped it)

In other issues people had with Karma and PhantomJS some suggested uncommenting the polyfills.ts file. I figured that might be related since the error seems to be coming from the polyfills bundled file so I tried running the tests with the polyfills commented out and also with them uncommented out and it didn't make a difference either way.

Here is my karma.conf.js file: http://plnkr.co/edit/SlYdbKzqddBwmdKNMK0U?p=catalogue

  • What is the expected behavior?

Expected behavior should be the same as when I run the tests with Chrome as a browser which is that the tests should all pass.

  • What is the motivation / use case for changing the behavior?

It doesn't work with PhantomJS. I previously posted a question on Stack Overflow and someone said this was a known issue but I didn't see any issues logged on this repo so I just wanted to check if it was known with this project.

@codymikol
Copy link
Owner

closing as this is an older ticket and the provided config does not seem to reference karma-webpack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants