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

Defend against run events firing in the wrong order. #111

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for

var initializeXmlForBrowser = function (browser) {
var timestamp = (new Date()).toISOString().substr(0, 19)
if( suites == null ) {
suites = Object.create(null) // OnRunStart() didn't fire yet, but it's not too late..
}
var suite = suites[browser.id] = builder.create('testsuite')
suite.att('name', browser.name)
.att('package', pkgName)
Expand Down Expand Up @@ -77,7 +80,10 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for
} else {
newOutputFile = path.join(outputDir, 'TESTS.xml')
}


if( suites == null ) {
return // Initialisation hasn't run yet - bail out.
}
var xmlToOutput = suites[browser.id]
if (!xmlToOutput) {
return // don't die if browser didn't start
Expand Down Expand Up @@ -120,6 +126,9 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for

// "browser_complete" - a test run has completed in _this_ browser
this.onBrowserComplete = function (browser) {
if( suites == null ) {
return // initialisation hasn't run yet - bail out.
}
var suite = suites[browser.id]
var result = browser.lastResult
if (!suite || !result) {
Expand All @@ -143,6 +152,10 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for
}

this.specSuccess = this.specSkipped = this.specFailure = function (browser, result) {

if( suites == null ) {
return; // Initialisation hasn't run yet, so no suites object, so no results.
}
var testsuite = suites[browser.id]

if (!testsuite) {
Expand Down