Starting from karma 2.0.1, the JSON reporters available:
are all failing as Karma now returns an object with a circular reference and all the reporters use JSON.stringify to generate their reports.
Expected behaviour
The JSON reporters should continue to work as they were previously.
Actual behaviour
Running a simple test with karma-json-reporter produces:
Chrome 67.0.3396 (Mac OS X 10.13.5): Executed 43 of 43 SUCCESS (9.014 secs / 8.844 secs)
10 07 2018 11:30:43.905:ERROR [karma]: TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
at /Users/cedric/Code/ninjasquad/ponyracer/node_modules/karma-json-reporter/index.js:35:24
at /Users/cedric/Code/ninjasquad/ponyracer/node_modules/karma/lib/helper.js:145:7
at /Users/cedric/Code/ninjasquad/ponyracer/node_modules/graceful-fs/polyfills.js:287:18
at FSReqWrap.oncomplete (fs.js:153:5)
Environment Details
- Karma version (output of
karma --version): 2.0.2 (same issue with 2.0.3 and 2.0.4)
- Relevant part of your
karma.config.js file
module.exports = function (config) {
config.set({
basePath: '',
browserNoActivityTimeout: 30000,
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-firefox-launcher'),
require('karma-json-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: [ 'html', 'json-summary'],
fixWebpackSourcePaths: true
},
jsonReporter: {
stdout: false,
outputFile: '../results/karma-results.json'
},
reporters: ['progress', 'json', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Steps to reproduce the behaviour
- Add
karma-json-reporter to karma.config.js
- Run the tests
Other info
After a brief analysis, it looks like the migration of the Browser class to ES2015 introduced the regression (see bb012e2) as it added a bunch of fields on the Browser object, some of them self referencing.
Starting from karma
2.0.1, the JSON reporters available:are all failing as Karma now returns an object with a circular reference and all the reporters use
JSON.stringifyto generate their reports.Expected behaviour
The JSON reporters should continue to work as they were previously.
Actual behaviour
Running a simple test with
karma-json-reporterproduces:Chrome 67.0.3396 (Mac OS X 10.13.5): Executed 43 of 43 SUCCESS (9.014 secs / 8.844 secs) 10 07 2018 11:30:43.905:ERROR [karma]: TypeError: Converting circular structure to JSON at JSON.stringify (<anonymous>) at /Users/cedric/Code/ninjasquad/ponyracer/node_modules/karma-json-reporter/index.js:35:24 at /Users/cedric/Code/ninjasquad/ponyracer/node_modules/karma/lib/helper.js:145:7 at /Users/cedric/Code/ninjasquad/ponyracer/node_modules/graceful-fs/polyfills.js:287:18 at FSReqWrap.oncomplete (fs.js:153:5)Environment Details
karma --version): 2.0.2 (same issue with 2.0.3 and 2.0.4)karma.config.jsfileSteps to reproduce the behaviour
karma-json-reportertokarma.config.jsOther info
After a brief analysis, it looks like the migration of the
Browserclass to ES2015 introduced the regression (see bb012e2) as it added a bunch of fields on theBrowserobject, some of them self referencing.