New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

krusty-jasmine-reporter

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

krusty-jasmine-reporter - npm Package Compare versions

Comparing version

to
1.0.0

309

bin/models.js
/* jshint node: true */
'use strict';
var format = require('util').format;
var ERROR = 'error';
var FAILED = 'failed';
var PENDING = 'pending';
/**
* The module containing models used by the krutsty jasmine reporter
* @param {util.format} format
* @returns {Object}
* TestSuite is a model that represents the contents inside of the <testsuite> node in the xml file. The constructor
* receives the base properties. TestCases are added to the test suite as the tests are being ran. When completed,
* there is a getSerialized method that will return an xml representation of the data.
* @param {String} name
* @param {String} timeStamp ISO 8601 representation of the date and time
* @param {String} hostName
* @param {String} packageName
* @param {Number} id
* @constructor
*/
exports.wiretree = function krustyJasmineReporterModelsModule(format) {
var ERROR = 'error';
var FAILED = 'failed';
var PENDING = 'pending';
function TestSuite(name, timeStamp, hostName, packageName, id) {
this.testCases = [];
this.name = name;
this.timeStamp = timeStamp;
this.hostName = hostName;
this.package = packageName;
this.id = id;
}
/**
* TestSuite is a model that represents the contents inside of the <testsuite> node in the xml file. The constructor
* receives the base properties. TestCases are added to the test suite as the tests are being ran. When completed,
* there is a getSerialized method that will return an xml representation of the data.
* @param {String} name
* @param {String} timeStamp ISO 8601 representation of the date and time
* @param {String} hostName
* @param {String} packageName
* @param {Number} id
* @constructor
*/
function TestSuite(name, timeStamp, hostName, packageName, id) {
this.testCases = [];
this.name = name;
this.timeStamp = timeStamp;
this.hostName = hostName;
this.package = packageName;
this.id = id;
/**
* Adds a test case to the list of test cases.
* @param {TestCase} testCase
*/
TestSuite.prototype.addTestCase = function addTestCase(testCase) {
if (testCase && testCase instanceof TestCase) {
this.testCases.push(testCase);
}
};
/**
* Adds a test case to the list of test cases.
* @param {TestCase} testCase
*/
TestSuite.prototype.addTestCase = function addTestCase(testCase) {
if (testCase && testCase instanceof TestCase) {
this.testCases.push(testCase);
}
};
/**
* Calculates how long it took to run all of the test cases for the suite.
* @returns {String}
*/
TestSuite.prototype.getTime = function getTime() {
return this.testCases.reduce(getSumOfTestCaseTimes, 0).toFixed(3);
/**
* Calculates how long it took to run all of the test cases for the suite.
* @returns {String}
* Calculates the sum of all test case times.
* @param {TestCase} prevTestCase
* @param {TestCase} currentTestCase
* @returns {Number}
*/
TestSuite.prototype.getTime = function getTime() {
return this.testCases.reduce(getSumOfTestCaseTimes, 0).toFixed(3);
function getSumOfTestCaseTimes(prevTestCase, currentTestCase) {
return prevTestCase + currentTestCase.time;
}
};
/**
* Calculates the sum of all test case times.
* @param {TestCase} prevTestCase
* @param {TestCase} currentTestCase
* @returns {Number}
*/
function getSumOfTestCaseTimes(prevTestCase, currentTestCase) {
return prevTestCase + currentTestCase.time;
}
};
/**
* Returns the number of test cases run for the suite.
* @returns {Number}
*/
TestSuite.prototype.getTestCount = function getTestCount() {
return this.testCases.length;
};
/**
* Returns the number of test cases run for the suite.
* @returns {Number}
*/
TestSuite.prototype.getTestCount = function getTestCount() {
return this.testCases.length;
};
/**
* Return the issue count. Valid issues include ['error'], ['failed'], ['pending'].
* @param {String} [issueType] 'error', 'failed', or 'pending'. Defaults to 'failed'.
* @returns {Number}
*/
TestSuite.prototype.getIssueCount = function getFailureCount(issueType) {
// default to failed if nothing is passed
if (!issueType) {
issueType = FAILED;
}
return this.testCases.filter(statusCountFilter).length;
/**
* Return the issue count. Valid issues include ['error'], ['failed'], ['pending'].
* @param {String} [issueType] 'error', 'failed', or 'pending'. Defaults to 'failed'.
* Increments failure count
* @param {Number} prevTestCase
* @param {TestCase} currentTestCase
* @returns {Number}
*/
TestSuite.prototype.getIssueCount = function getFailureCount(issueType) {
// default to failed if nothing is passed
if (!issueType) {
issueType = FAILED;
}
function statusCountFilter(currentTestCase) {
return currentTestCase.status === issueType;
}
};
return this.testCases.filter(statusCountFilter).length;
/**
* Serializes the data in the test suite into the proper format that can be read by Jenkins. Here is an example of
* the data that might be returned.
*
* <testsuites>
* <testsuite name="My Reporter" package="My Reporter Package" timestamp="2014-07-23T22:40:18.211Z" id="0"
* hostname="localhost" tests="256" errors="0" failures="0" skipped="0" time="0.893">
* <testcase classname="integration tests basic" name="should receive a 200" time="0.047"></testcase>
* </testsuite>
* </testsuites>
*
* @returns {String}
*/
TestSuite.prototype.getSerialized = function getSerialized() {
var serializedTestCases = this.testCases.reduce(serializeTestCase, '');
return format(
'<testsuites><testsuite name="%s" package="%s" timestamp="%s" id="%s" hostname="%s" tests="%s" errors="%s" ' +
'failures="%s" ' + 'skipped="%s" time="%s">%s</testsuite></testsuites>',
this.name, this.package, this.timeStamp, this.id, this.hostName, this.getTestCount(), this.getIssueCount(ERROR),
this.getIssueCount(FAILED), this.getIssueCount(PENDING), this.getTime(), serializedTestCases);
/**
* Increments failure count
* @param {Number} prevTestCase
* @param {TestCase} currentTestCase
* @returns {Number}
*/
function statusCountFilter(currentTestCase) {
return currentTestCase.status === issueType;
}
};
/**
* Serializes the data in the test suite into the proper format that can be read by Jenkins. Here is an example of
* the data that might be returned.
*
* <testsuites>
* <testsuite name="My Reporter" package="My Reporter Package" timestamp="2014-07-23T22:40:18.211Z" id="0"
* hostname="localhost" tests="256" errors="0" failures="0" skipped="0" time="0.893">
* <testcase classname="integration tests basic" name="should receive a 200" time="0.047"></testcase>
* </testsuite>
* </testsuites>
*
* Used by the reduce function, this will concatenate the previous accumulated string with the current serialized
* test case. This is effectively used to concatenate all the serialized test cases together.
* @param {String} prevTestCase
* @param {TestCase} currentTestCase
* @returns {String}
*/
TestSuite.prototype.getSerialized = function getSerialized() {
var serializedTestCases = this.testCases.reduce(serializeTestCase, '');
return format(
'<testsuites><testsuite name="%s" package="%s" timestamp="%s" id="%s" hostname="%s" tests="%s" errors="%s" ' +
'failures="%s" ' + 'skipped="%s" time="%s">%s</testsuite></testsuites>',
this.name, this.package, this.timeStamp, this.id, this.hostName, this.getTestCount(), this.getIssueCount(ERROR),
this.getIssueCount(FAILED), this.getIssueCount(PENDING), this.getTime(), serializedTestCases);
function serializeTestCase(prevTestCase, currentTestCase) {
return prevTestCase + currentTestCase.getSerialized();
}
};
/**
* Used by the reduce function, this will concatenate the previous accumulated string with the current serialized
* test case. This is effectively used to concatenate all the serialized test cases together.
* @param {String} prevTestCase
* @param {TestCase} currentTestCase
* @returns {String}
*/
function serializeTestCase(prevTestCase, currentTestCase) {
return prevTestCase + currentTestCase.getSerialized();
}
};
/**
* TestCase is a model that represents the data in a single test case.
* @param {Object} result
* @param {Number} time The time it took to run the test. An example would be, "0.800"
* @param {String} packageName The package name to be prefixed on the classname
* @constructor
*/
function TestCase(result, time, packageName) {
this.classname = packageName + "." + (result.fullName.substr(0, result.fullName.indexOf(result.description) - 1) ||
result.fullName);
this.name = result.description;
this.time = time;
this.status = result.status;
this.result = result;
}
/**
* TestCase is a model that represents the data in a single test case.
* @param {Object} result
* @param {Number} time The time it took to run the test. An example would be, "0.800"
* @param {String} packageName The package name to be prefixed on the classname
* @constructor
*/
function TestCase(result, time, packageName) {
this.classname = packageName + "." + (result.fullName.substr(0, result.fullName.indexOf(result.description) - 1) ||
result.fullName);
this.name = result.description;
this.time = time;
this.status = result.status;
this.result = result;
/**
* Returns a serialized version of the test case data. An example might be:
*
* <testcase classname="integration tests basic" name="should receive a 200" time="0.047"></testcase>
*
* @returns {String}
*/
TestCase.prototype.getSerialized = function () {
var testCaseMessage = format.bind(null, '<testcase classname="%s" name="%s" time="%s">',
this.classname.replace(/"/g, '\''), this.name.replace(/"/g, '\''), this.time.toFixed(3));
var cData = format.bind(null, '<![CDATA[%s]]>');
var errorMessage = cData(this.result.failedExpectations.reduce(concatErrorMessages, ''));
if (this.status === ERROR) {
testCaseMessage = testCaseMessage
.bind(null, format('<error message="test failure">%s</error>', errorMessage));
} else if (this.status === FAILED) {
testCaseMessage = testCaseMessage
.bind(null, format('<failure message="test failure">%s</failure>', errorMessage));
} else if (this.status === PENDING) {
testCaseMessage = testCaseMessage.bind(null, '<skipped></skipped>');
}
testCaseMessage = testCaseMessage.bind(null, '</testcase>');
return testCaseMessage();
/**
* Returns a serialized version of the test case data. An example might be:
*
* <testcase classname="integration tests basic" name="should receive a 200" time="0.047"></testcase>
*
* Used by the reduce function, this will concatenate the previous value with the current stack trace.
* @param {String} prev
* @param {Object} current
* @returns {String}
*/
TestCase.prototype.getSerialized = function () {
var testCaseMessage = format.bind(null, '<testcase classname="%s" name="%s" time="%s">',
this.classname.replace(/"/g, '\''), this.name.replace(/"/g, '\''), this.time.toFixed(3));
var cData = format.bind(null, '<![CDATA[%s]]>');
var errorMessage = cData(this.result.failedExpectations.reduce(concatErrorMessages, ''));
function concatErrorMessages(prev, current) {
return prev + current.stack;
}
};
if (this.status === ERROR) {
testCaseMessage = testCaseMessage
.bind(null, format('<error message="test failure">%s</error>', errorMessage));
} else if (this.status === FAILED) {
testCaseMessage = testCaseMessage
.bind(null, format('<failure message="test failure">%s</failure>', errorMessage));
} else if (this.status === PENDING) {
testCaseMessage = testCaseMessage.bind(null, '<skipped></skipped>');
}
testCaseMessage = testCaseMessage.bind(null, '</testcase>');
return testCaseMessage();
/**
* Used by the reduce function, this will concatenate the previous value with the current stack trace.
* @param {String} prev
* @param {Object} current
* @returns {String}
*/
function concatErrorMessages(prev, current) {
return prev + current.stack;
}
};
return {
TestSuite: TestSuite,
TestCase: TestCase,
ERROR: ERROR,
FAILED: FAILED,
PENDING: PENDING
};
module.exports = {
TestSuite: TestSuite,
TestCase: TestCase,
ERROR: ERROR,
FAILED: FAILED,
PENDING: PENDING
};
/* jshint node: true */
'use strict';
var prettyData = require('pretty-data').pd;
var os = require('os');
var fs = require('fs');
var format = require('util').format;
var models = require('./models');
/**
* The Krusty Jasmine JUnit Reporter Module
* @param {Object} models
* @param {Object} prettyData
* @param {Object} os
* @param {Function} fsWriteThen
* @param {jasmine.Timer} timer
* @param {jasmine.Timer} specTimer
* @param {Date} date
* @returns {Object}
* The KrustyJasmineJUnitReporter is a Jasmine reporter that is used to generate an XML data format representing
* the Jasmine test results. This reporter will be used to generate an XML file that will be read and interpreted
* by Jenkins.
* @param {Object} options
* @constructor
*/
exports.wiretree = function krustyJasmineReporterModule(models, prettyData, os, fsWriteThen, timer, specTimer, date) {
function KrustyJasmineJUnitReporter (options) {
var testSuite;
var specTimer = options.specTimer;
/**
* The KrustyJasmineJUnitReporter is a Jasmine reporter that is used to generate an XML data format representing
* the Jasmine test results. This reporter will be used to generate an XML file that will be read and interpreted
* by Jenkins.
* @param {Object} options
* @constructor
* Called when the Jasmine process is started. Variables and the TestSuite are initialized here.
*/
function KrustyJasmineJUnitReporter(options) {
var testSuite;
this.jasmineStarted = function jasmineStarted () {
testSuite = new models.TestSuite(options.JUnitReportSuiteName, new Date().toISOString(), os.hostname(),
options.JUnitReportPackageName, 0);
};
/**
* Called when the Jasmine process is started. Variables and the TestSuite are initialized here.
* @param {Object} specInfo
*/
this.jasmineStarted = function jasmineStarted(specInfo) {
testSuite = new models.TestSuite(options.JUnitReportSuiteName, date.toISOString(), os.hostname(),
options.JUnitReportPackageName, 0);
timer.start();
};
/**
* Called when the jasmine process is finished. At this point, the data can be serialized and output to a file.
*/
this.jasmineDone = function jasmineDone(done) {
/**
* Called when the jasmine process is finished. At this point, the data can be serialized and output to a file.
*/
this.jasmineDone = function jasmineDone () {
if (options.JUnitReportSavePath && options.JUnitReportFilePrefix) {
var report = prettyData.xml(testSuite.getSerialized());
var seconds = timer.elapsed() / 1000;
var totalErrors = testSuite.getIssueCount(models.FAILED) + testSuite.getIssueCount(models.ERROR) +
testSuite.getIssueCount(models.PENDING);
var completed = options.done || function () {};
done = done || function () {};
var filePath = options.JUnitReportSavePath + options.JUnitReportFilePrefix + '.xml';
console.log('finished in ', seconds, ' seconds');
if (options.JUnitReportSavePath && options.JUnitReportFilePrefix) {
fsWriteThen(options.JUnitReportSavePath + options.JUnitReportFilePrefix + ".xml", report, 'utf8')
.then(function () {
console.log('Wrote report file to ', options.JUnitReportSavePath + options.JUnitReportFilePrefix + ".xml");
completed(totalErrors === 0);
})
.catch(function (e) {
console.log('Error writing Jasmine Reports to ', options.JUnitReportSavePath +
options.JUnitReportFilePrefix + ".xml", e);
completed(false);
}).done(done);
} else {
completed(totalErrors === 0);
done();
try {
fs.writeFileSync(filePath, report);
} catch(e) {
console.error(e);
throw e;
}
};
console.log('Wrote report file to ', filePath);
}
};
/**
* Called when a spec is started. The only thing needed to be done here is to start the spec timer.
*/
this.specStarted = function specStarted () {
specTimer.start();
};
/**
* Called when a spec is started. The only thing needed to be done here is to start the spec timer.
*/
this.specStarted = specTimer.start.bind(specTimer);
/**
* Called when a spec completes. In this callback, the time it took to run the test case is recorded and a new
* TestCase model is instantiated with that time. The new test case is then added to the test suite.
* @param {Object} result
*/
this.specDone = function specDone (result) {
var seconds = specTimer.elapsed() / 1000;
var testCase = new models.TestCase(result, seconds, options.JUnitReportPackageName);
testSuite.addTestCase(testCase);
};
}
/**
* Called when a spec completes. In this callback, the time it took to run the test case is recorded and a new
* TestCase model is instantiated with that time. The new test case is then added to the test suite.
* @param {Object} result
*/
this.specDone = function specDone (result) {
var seconds = specTimer.elapsed() / 1000;
var testCase = new models.TestCase(result, seconds, options.JUnitReportPackageName);
testSuite.addTestCase(testCase);
};
}
return {
KrustyJasmineJUnitReporter: KrustyJasmineJUnitReporter
};
module.exports = {
KrustyJasmineJUnitReporter: KrustyJasmineJUnitReporter
};

@@ -6,21 +6,3 @@ /* jshint node: true */

var models = require('./bin/models');
var Wiretree = require('wiretree');
var prettyData = require('pretty-data').pd;
var os = require('os');
var Promise = require('promise');
var fsWriteThen = Promise.denodeify(require('fs').writeFile);
// Inject Dependencies
var wireTree = new Wiretree(__dirname);
wireTree.add(format, 'format');
wireTree.add(models, 'models');
wireTree.add(prettyData, 'prettyData');
wireTree.add(os, 'os');
wireTree.add(fsWriteThen, 'fsWriteThen');
wireTree.add(new jasmine.Timer(), 'timer');
wireTree.add(new jasmine.Timer(), 'specTimer');
wireTree.add(new Date(), 'date');
wireTree.load('./bin/reporter.js', 'reporter');
// Export the Krusty Jasmine JUnit Reporter
module.exports = wireTree.get('reporter');
module.exports = require('./bin/reporter');
{
"name": "krusty-jasmine-reporter",
"version": "0.0.2",
"version": "1.0.0",
"description": "A reporter used to generate jasmine to JUnit results that can be interpreted by Jenkins",

@@ -22,8 +22,7 @@ "main": "index.js",

"dependencies": {
"pretty-data": "0.40.0",
"promise": "5.0.0",
"wiretree": "0.2.5"
"pretty-data": "0.40.0"
},
"devDependencies": {
"minijasminenodewrap": "0.0.5"
"minijasminenodewrap": "0.0.5",
"rewire": "2.3.3"
},

@@ -30,0 +29,0 @@ "bugs": {

/* jshint node: true */
'use strict';
var modelsModule = require('../../bin/models').wiretree;
var format = require('util').format;
var models = require('../../bin/models');

@@ -126,7 +125,6 @@ var dataProvider = [

describe('test adding an object to the TestSuite instead of a TestCase', function () {
var models, testSuite;
var testSuite;
var data = dataProvider[0];
beforeEach(function () {
models = modelsModule(format);
testSuite = new models.TestSuite(data.testSuiteData.name, data.testSuiteData.timeStamp,

@@ -143,6 +141,4 @@ data.testSuiteData.hostName, data.testSuiteData.packageName, data.testSuiteData.id);

function commonSetup(data) {
var models, testSuite, testCase, actualSerializedTestSuite;
var testSuite, testCase, actualSerializedTestSuite;
models = modelsModule(format);
testSuite = new models.TestSuite(data.testSuiteData.name, data.testSuiteData.timeStamp,

@@ -149,0 +145,0 @@ data.testSuiteData.hostName, data.testSuiteData.packageName, data.testSuiteData.id);

/* jshint node: true */
'use strict';
var reporterModule = require('../../bin/reporter').wiretree;
var Promise = require('promise');
var rewire = require('rewire');
var reporter = rewire('../../bin/reporter');
describe('test initializing the Krusty Jasmine Reporter Module', function () {
var reporter, models, prettyData, os, fsWriteThen, testSuite, testCase, fsWriteThenPromise,
krustyJasmineJUnitReporter, options, timer, specTimer, date, stubDate, hostname,
testSuiteSerialized;
var models, prettyData, os, testSuite, testCase,
krustyJasmineJUnitReporter, options, specTimer, hostname,
testSuiteSerialized, writeFileSync, revert;
beforeEach(function () {
stubDate = '2014-07-31';
hostname = 'localhost';

@@ -18,4 +17,3 @@ testSuiteSerialized = 'serialized-test-suite';

addTestCase: jasmine.createSpy('addTestCase'),
getSerialized: jasmine.createSpy('getSerialized').and.returnValue(testSuiteSerialized),
getIssueCount: jasmine.createSpy('getIssueCount').and.returnValue(0)
getSerialized: jasmine.createSpy('getSerialized').and.returnValue(testSuiteSerialized)
};

@@ -35,14 +33,6 @@ testCase = {};

fsWriteThenPromise = Promise.resolve();
fsWriteThen = jasmine.createSpy('fsWriteThen').and.returnValue(fsWriteThenPromise);
timer = jasmine.createSpyObj('timer', ['start', 'elapsed']);
specTimer = jasmine.createSpyObj('specTimer', ['start', 'elapsed']);
date = jasmine.createSpyObj('date', ['toISOString']);
reporter = reporterModule(models, prettyData, os, fsWriteThen, timer, specTimer, date);
options = {
done: jasmine.createSpy('done'),
specTimer: specTimer,
JUnitReportSuiteName: 'Suite Name',

@@ -54,5 +44,18 @@ JUnitReportPackageName: 'Package Name',

date.toISOString.and.returnValue(stubDate);
os.hostname.and.returnValue(hostname);
writeFileSync = jasmine.createSpy('writeFileSync');
revert = reporter.__set__({
os: os,
models: models,
prettyData: prettyData,
fs: {
writeFileSync: writeFileSync
},
console: {
log: function () {}
}
});
krustyJasmineJUnitReporter = new reporter.KrustyJasmineJUnitReporter(options);

@@ -62,4 +65,4 @@ krustyJasmineJUnitReporter.jasmineStarted({});

it('should return an instance of KrustyJasmineJUnitReporter', function () {
expect(krustyJasmineJUnitReporter instanceof reporter.KrustyJasmineJUnitReporter).toBeTruthy();
afterEach(function () {
revert();
});

@@ -69,17 +72,9 @@

it('should instantiate models.TestSuite with appropriate data', function () {
expect(models.TestSuite).toHaveBeenCalledWith(options.JUnitReportSuiteName, stubDate, hostname,
expect(models.TestSuite).toHaveBeenCalledWith(options.JUnitReportSuiteName, jasmine.any(String), hostname,
options.JUnitReportPackageName, 0);
});
it('should call date.toISOString', function () {
expect(date.toISOString).toHaveBeenCalled();
});
it('should call os.hostname', function () {
expect(os.hostname).toHaveBeenCalled();
});
it('should call timer.start', function () {
expect(timer.start).toHaveBeenCalled();
});
});

@@ -116,5 +111,5 @@

describe('test calling jasmineDone and writing to output file without errors', function () {
beforeEach(function (done) {
beforeEach(function () {
initializeJasmineDoneMocks();
krustyJasmineJUnitReporter.jasmineDone(done);
krustyJasmineJUnitReporter.jasmineDone();
});

@@ -126,46 +121,19 @@

it('should call getIssueCount with failed', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.FAILED);
it('should call writeFileSync with appropriate values', function () {
expect(writeFileSync).toHaveBeenCalledWith(options.JUnitReportSavePath + options.JUnitReportFilePrefix + ".xml",
testSuiteSerialized);
});
it('should call getIssueCount with error', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.ERROR);
});
it('should call getIssueCount with pending', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.PENDING);
});
it('should call fsWriteThen with appropriate values', function () {
expect(fsWriteThen).toHaveBeenCalledWith(options.JUnitReportSavePath + options.JUnitReportFilePrefix + ".xml",
testSuiteSerialized, 'utf8');
});
it('should call done with 0 errors', function () {
expect(options.done).toHaveBeenCalledWith(true);
});
});
describe('test calling jasmineDone and writing to output file with errors', function () {
beforeEach(function (done) {
testSuite.getIssueCount.and.callFake(function (issueType) {
return (issueType === models.FAILED) ? 1 : 0;
});
beforeEach(function () {
initializeJasmineDoneMocks();
krustyJasmineJUnitReporter.jasmineDone(done);
krustyJasmineJUnitReporter.jasmineDone();
});
it('should call done with errors', function () {
expect(options.done).toHaveBeenCalledWith(false);
});
});
describe('test calling jasmineDone and catching an error while writing', function () {
beforeEach(function (done) {
beforeEach(function () {
initializeJasmineDoneMocks();
fsWriteThenPromise = Promise.reject();
fsWriteThen.and.returnValue(fsWriteThenPromise);
krustyJasmineJUnitReporter.jasmineDone(done);
krustyJasmineJUnitReporter.jasmineDone();
});

@@ -177,74 +145,26 @@

it('should call getIssueCount with failed', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.FAILED);
it('should call writeFileSync with appropriate values', function () {
expect(writeFileSync).toHaveBeenCalledWith(options.JUnitReportSavePath + options.JUnitReportFilePrefix + ".xml",
testSuiteSerialized);
});
it('should call getIssueCount with error', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.ERROR);
});
it('should call getIssueCount with pending', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.PENDING);
});
it('should call fsWriteThen with appropriate values', function () {
expect(fsWriteThen).toHaveBeenCalledWith(options.JUnitReportSavePath + options.JUnitReportFilePrefix + ".xml",
testSuiteSerialized, 'utf8');
});
it('should call done with 0 errors', function () {
expect(options.done).toHaveBeenCalledWith(false);
});
});
describe('test jasmineDone if the save path or file prefix have not been defined', function () {
beforeEach(function (done) {
beforeEach(function () {
initializeJasmineDoneMocks();
delete options.JUnitReportSavePath;
krustyJasmineJUnitReporter.jasmineDone(done);
krustyJasmineJUnitReporter.jasmineDone();
});
it('should call prettyData.xml', function () {
expect(prettyData.xml).toHaveBeenCalledWith(testSuiteSerialized);
it('should not call prettyData.xml', function () {
expect(prettyData.xml).not.toHaveBeenCalled();
});
it('should call getIssueCount with failed', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.FAILED);
it('should NOT call writeFileSync', function () {
expect(writeFileSync).not.toHaveBeenCalled();
});
it('should call getIssueCount with error', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.ERROR);
});
it('should call getIssueCount with pending', function () {
expect(testSuite.getIssueCount).toHaveBeenCalledWith(models.PENDING);
});
it('should NOT call fsWriteThen', function () {
expect(fsWriteThen).not.toHaveBeenCalled();
});
it('should call done with 0 errors', function () {
expect(options.done).toHaveBeenCalledWith(true);
});
});
describe('test calling jasmineDone without a done function in options', function () {
beforeEach(function () {
initializeJasmineDoneMocks();
delete options.done;
delete options.JUnitReportFilePrefix;
krustyJasmineJUnitReporter.jasmineDone();
});
it('should complete without the done function', function () {
expect(options.done).toBeUndefined();
});
});
function initializeJasmineDoneMocks() {
timer.elapsed.and.returnValue(2000);
prettyData.xml.and.returnValue(testSuiteSerialized);

@@ -251,0 +171,0 @@ }