karma-runner / karma-phantomjs-launcher

A Karma plugin. Launcher for PhantomJS.
MIT License
281 stars 121 forks source link

TypeError: JSON.stringify cannot serialize cyclic structures #213

Open ricazhang opened 6 years ago

ricazhang commented 6 years ago

This is with version 1.0.4 of karma-phantomjs-launcher on a Windows 7 machine.

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: https://codepen.io/anon/pen/NYBypv