Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

karma-junit-reporter

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-junit-reporter - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

58

CHANGELOG.md

@@ -0,7 +1,63 @@

<a name="2.0.1"></a>
## [2.0.1](https://github.com/karma-runner/karma-junit-reporter/compare/v2.0.0...v2.0.1) (2019-10-07)
<a name="2.0.0"></a>
# [2.0.0](https://github.com/karma-runner/karma-junit-reporter/compare/v0.4.2...v2.0.0) (2016-05-03)
# [2.0.0](https://github.com/karma-runner/karma-junit-reporter/compare/v1.2.0...v2.0.0) (2019-10-07)
### Bug Fixes
* allow special characters and emoji in output ([59fd3c6](https://github.com/karma-runner/karma-junit-reporter/commit/59fd3c6))
### Chores
* **travis:** Drop old nodejs version: NO v10 ([#164](https://github.com/karma-runner/karma-junit-reporter/issues/164)) ([bc07177](https://github.com/karma-runner/karma-junit-reporter/commit/bc07177))
* remove support for node 6 ([435cb5e](https://github.com/karma-runner/karma-junit-reporter/commit/435cb5e))
### Features
* support for new XML format (per SonarQube) ([b0984e0](https://github.com/karma-runner/karma-junit-reporter/commit/b0984e0))
### BREAKING CHANGES
* Drop Support for Node 6, to make it possible to use async/await in karma codebase.
* **travis:** no support for node < 6
* node 10 not supported by libxmljs-mt
<a name="1.2.0"></a>
# [1.2.0](https://github.com/karma-runner/karma-junit-reporter/compare/v1.1.0...v1.2.0) (2016-12-06)
### Bug Fixes
* initialize var suites early ([e09acb2](https://github.com/karma-runner/karma-junit-reporter/commit/e09acb2))
* release memory held by a testsuite after we're done with it. ([eacf8bb](https://github.com/karma-runner/karma-junit-reporter/commit/eacf8bb))
* remove unnecessary nulling out of `suites` ([4202ee8](https://github.com/karma-runner/karma-junit-reporter/commit/4202ee8)), closes [#99](https://github.com/karma-runner/karma-junit-reporter/issues/99)
<a name="1.1.0"></a>
# [1.1.0](https://github.com/karma-runner/karma-junit-reporter/compare/v1.0.0...v1.1.0) (2016-06-26)
### Bug Fixes
* add defensive checks to safely handle browser disconnects. ([485d87a](https://github.com/karma-runner/karma-junit-reporter/commit/485d87a))
<a name="1.0.0"></a>
# [1.0.0](https://github.com/karma-runner/karma-junit-reporter/compare/v0.4.2...v1.0.0) (2016-05-03)
<a name="0.4.2"></a>

@@ -8,0 +64,0 @@ ## [0.4.2](https://github.com/karma-runner/karma-junit-reporter/compare/v0.4.1...v0.4.2) (2016-04-08)

@@ -7,2 +7,8 @@ var os = require('os')

/* XML schemas supported by the reporter: 'xmlVersion' in karma.conf.js,
'XMLconfigValue' as variable here.
0 = "old", original XML format. For example, SonarQube versions prior to 6.2
1 = first amended version. Compatible with SonarQube starting from 6.2
*/
// concatenate test suite(s) and test description by default

@@ -16,2 +22,3 @@ function defaultNameFormatter (browser, result) {

var reporterConfig = config.junitReporter || {}
// All reporterConfig.something are for reading flags from the Karma config file
var pkgName = reporterConfig.suite || ''

@@ -24,4 +31,8 @@ var outputDir = reporterConfig.outputDir

var properties = reporterConfig.properties
var suites
// The below two variables have to do with adding support for new SonarQube XML format
var XMLconfigValue = reporterConfig.xmlVersion
var NEWXML
// We need one global variable for the tag <file> to be visible to functions
var exposee
var suites = []
var pendingFileWritings = 0

@@ -31,2 +42,13 @@ var fileWritingFinished = function () {}

// The NEWXML is just sugar, a flag. Remove it when there are more than 2
// supported XML output formats.
if (!XMLconfigValue) {
XMLconfigValue = 0
NEWXML = false
} else {
// Slack behavior: "If defined, assume to be 1" since we have only two formats now
XMLconfigValue = 1
NEWXML = true
}
if (outputDir == null) {

@@ -50,6 +72,13 @@ outputDir = '.'

// Creates the outermost XML element: <unitTest>
var initializeXmlForBrowser = function (browser) {
var timestamp = (new Date()).toISOString().substr(0, 19)
var suite = suites[browser.id] = builder.create('testsuite')
suite.att('name', browser.name)
var suite
if (NEWXML) {
suite = suites[browser.id] = builder.create('unitTest')
suite.att('version', '1')
exposee = suite.ele('file', {'path': 'fixedString'})
} else {
suite = suites[browser.id] = builder.create('testsuite')
suite.att('name', browser.name)
.att('package', pkgName)

@@ -59,10 +88,10 @@ .att('timestamp', timestamp)

.att('hostname', os.hostname())
var propertiesElement = suite.ele('properties')
propertiesElement.ele('property', {name: 'browser.fullName', value: browser.fullName})
var propertiesElement = suite.ele('properties')
propertiesElement.ele('property', {name: 'browser.fullName', value: browser.fullName})
// add additional properties passed in through the config
for (var property in properties) {
if (properties.hasOwnProperty(property)) {
propertiesElement.ele('property', {name: property, value: properties[property]})
// add additional properties passed in through the config
for (var property in properties) {
if (properties.hasOwnProperty(property)) {
propertiesElement.ele('property', {name: property, value: properties[property]})
}
}

@@ -72,3 +101,5 @@ }

// This function takes care of writing the XML into a file
var writeXmlForBrowser = function (browser) {
// Define the file name using rules
var safeBrowserName = browser.name.replace(/ /g, '_')

@@ -89,2 +120,3 @@ var newOutputFile

var xmlToOutput = suites[browser.id]
if (!xmlToOutput) {

@@ -110,11 +142,22 @@ return // don't die if browser didn't start

// Return a 'safe' name for test. This will be the name="..." content in XML.
var getClassName = function (browser, result) {
var browserName = browser.name.replace(/ /g, '_').replace(/\./g, '_') + '.'
return (useBrowserName ? browserName : '') + (pkgName ? pkgName + '.' : '') + result.suite[0]
var name = ''
// configuration tells whether to use browser name at all
if (useBrowserName) {
name += browser.name
.replace(/ /g, '_')
.replace(/\./g, '_') + '.'
}
if (pkgName) {
name += '.'
}
if (result.suite && result.suite.length > 0) {
name += result.suite.join(' ')
}
return name
}
// "run_start" - a test run is beginning for all browsers
this.onRunStart = function (browsers) {
suites = Object.create(null)
// TODO(vojta): remove once we don't care about Karma 0.10

@@ -124,2 +167,3 @@ browsers.forEach(initializeXmlForBrowser)

// "browser_start" - a test run is beginning in _this_ browser
this.onBrowserStart = function (browser) {

@@ -129,2 +173,4 @@ initializeXmlForBrowser(browser)

// "browser_complete" - a test run has completed in _this_ browser
// writes the XML to file and releases memory
this.onBrowserComplete = function (browser) {

@@ -137,25 +183,65 @@ var suite = suites[browser.id]

suite.att('tests', result.total)
suite.att('errors', result.disconnected || result.error ? 1 : 0)
suite.att('failures', result.failed)
suite.att('time', (result.netTime || 0) / 1000)
if (!NEWXML) {
suite.att('tests', result.total ? result.total : 0)
suite.att('errors', result.disconnected || result.error ? 1 : 0)
suite.att('failures', result.failed ? result.failed : 0)
suite.att('time', (result.netTime || 0) / 1000)
suite.ele('system-out').dat(allMessages.join() + '\n')
suite.ele('system-err')
}
suite.ele('system-out').dat(allMessages.join() + '\n')
suite.ele('system-err')
writeXmlForBrowser(browser)
writeXmlForBrowser(browser)
// Release memory held by the test suite.
suites[browser.id] = null
}
// "run_complete" - a test run has completed on all browsers
this.onRunComplete = function () {
suites = null
allMessages.length = 0
}
// --------------------------------------------
// | Producing XML for individual testCase |
// --------------------------------------------
this.specSuccess = this.specSkipped = this.specFailure = function (browser, result) {
var spec = suites[browser.id].ele('testcase', {
var testsuite = suites[browser.id]
var validMilliTime
var spec
if (!testsuite) {
return
}
// New in the XSD schema: only name and duration. classname is obsoleted
if (NEWXML) {
if (!result.time || result.time === 0) {
validMilliTime = 1
} else {
validMilliTime = result.time
}
}
// create the tag for a new test case
/*
if (NEWXML) {
spec = testsuite.ele('testCase', {
name: nameFormatter(browser, result),
time: ((result.time || 0) / 1000),
classname: (typeof classNameFormatter === 'function' ? classNameFormatter : getClassName)(browser, result)
})
duration: validMilliTime })
}
*/
if (NEWXML) {
spec = exposee.ele('testCase', {
name: nameFormatter(browser, result),
duration: validMilliTime })
} else {
// old XML format. Code as-was
spec = testsuite.ele('testcase', {
name: nameFormatter(browser, result),
time: ((result.time || 0) / 1000),
classname: (typeof classNameFormatter === 'function' ? classNameFormatter : getClassName)(browser, result)
})
}
if (result.skipped) {

@@ -167,3 +253,8 @@ spec.ele('skipped')

result.log.forEach(function (err) {
spec.ele('failure', {type: ''}, formatError(err))
if (!NEWXML) {
spec.ele('failure', {type: ''}, formatError(err))
} else {
// In new XML format, an obligatory 'message' attribute in failure
spec.ele('failure', {message: formatError(err)})
}
})

@@ -170,0 +261,0 @@ }

53

package.json
{
"name": "karma-junit-reporter",
"version": "2.0.0",
"version": "2.0.1",
"description": "A Karma plugin. Report results in junit xml format.",

@@ -24,3 +24,3 @@ "main": "index.js",

"path-is-absolute": "^1.0.0",
"xmlbuilder": "3.1.0"
"xmlbuilder": "12.0.0"
},

@@ -30,18 +30,23 @@ "peerDependencies": {

},
"engines": {
"node": ">= 8"
},
"license": "MIT",
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^1.2.1",
"eslint-config-standard": "^4.1.0",
"eslint": "^6.5.1",
"eslint-config-standard": "^5.3.1",
"eslint-plugin-promise": "^1.3.2",
"eslint-plugin-standard": "^1.3.1",
"grunt": "^0.4.1",
"grunt-bump": "^0.5.0",
"grunt-cli": "^0.1.13",
"grunt-conventional-changelog": "^4.1.0",
"grunt-conventional-github-releaser": "^0.4.0",
"grunt-eslint": "^17.1.0",
"grunt": "^1.0.1",
"grunt-bump": "^0.8.0",
"grunt-cli": "^1.2.0",
"grunt-conventional-changelog": "^6.1.0",
"grunt-conventional-github-releaser": "^1.0.0",
"grunt-eslint": "^18.1.0",
"grunt-npm": "^0.0.2",
"grunt-simple-mocha": "^0.4.1",
"libxmljs": "^0.19.5",
"load-grunt-tasks": "^3.2.0",
"mocha": "^2.4.5",
"mocha": "^3.2.0",
"proxyquire": "^1.7.4",

@@ -52,17 +57,22 @@ "sinon": "^1.17.3",

"contributors": [
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Vojta Jina <vojta.jina@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Mark Ethan Trostler <mark@zzo.com>",
"johnjbarton <johnjbarton@johnjbarton.com>",
"hicom150 <hicom150@gmail.com>",
"Simen Bekkhus <sbekkhus91@gmail.com>",
"Friedel Ziegelmayer <friedel.ziegelmayer@gmail.com>",
"Simen Bekkhus <sbekkhus91@gmail.com>",
"Floris Kraak <randakar@gmail.com>",
"Julen Garcia Leunda <hicom150@gmail.com>",
"Janek Lasocki-Biczysko <iamjanek@gmail.com>",
"Craig Vermeer <craig@vermeers.net>",
"Janek Lasocki-Biczysko <j.lasocki-biczysko@intrallect.com>",
"John Haugeland <stonecypher@gmail.com>",
"Kira Cheung <killercentury@gmail.com>",
"greenkeeperio-bot <support@greenkeeper.io>",
"Larry Myers <larry@larrymyers.com>",
"Maksim Ryzhikov <rv.maksim@gmail.com>",
"Mark Ethan Trostler <mark@zzo.com>",
"Martin Leonhartsberger <mschrott@splunk.com>",
"Marvin Tam <thatmarvin@users.noreply.github.com>",
"Matthias Oßwald <matz3@users.noreply.github.com>",
"Mike Ng <mike.ng@optimizely.com>",
"Nikita Shirin <shirin.nikita@gmail.com>",
"Paweł Gesek <pgesek@soldevelo.com>",
"Phillip Johnsen <johphi@gmail.com>",

@@ -74,2 +84,3 @@ "Rob Richardson <robrich@robrich.org>",

"budde377 <budde377@gmail.com>",
"dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>",
"mon.asuncion <mon@englishcentral.com>",

@@ -82,5 +93,11 @@ "Adriaan Thomas <athomas@xebia.com>",

"Cesar Andreu <cesarandreu@gmail.com>",
"Christian Svensson <csvn.dev@gmail.com>",
"César Suárez Ortega <suarez.ortega.cesar@gmail.com>",
"David Pärsson <david@parsson.se>",
"Derek Schaller <dschaller@lyft.com>"
"Derek Schaller <dschaller@lyft.com>",
"Janek Lasocki-Biczysko <j.lasocki-biczysko@intrallect.com>",
"John Haugeland <stonecypher@gmail.com>",
"Jukka Paulin <jukka.paulin@gmail.com>",
"Kira Cheung <killercentury@gmail.com>"
]
}

@@ -35,4 +35,5 @@ # karma-junit-reporter

nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined // function (browser, result) to customize the classname attribute in xml testcase element,
properties: {} // key value pair of properties to add to the <properties> section of the report
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {}, // key value pair of properties to add to the <properties> section of the report
xmlVersion: null // use '1' if reporting to be per SonarQube 6.2 XML format
}

@@ -120,1 +121,2 @@ });

[homepage]: http://karma-runner.github.com
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc