Skip to content

Commit

Permalink
Merge pull request #2 from tomv564/update_jasmine
Browse files Browse the repository at this point in the history
More jasmine2 updates
  • Loading branch information
akhomchenko committed Jun 2, 2015
2 parents 6b8bb74 + e63ef2a commit ebd2500
Show file tree
Hide file tree
Showing 12 changed files with 560 additions and 580 deletions.
Expand Up @@ -62,7 +62,7 @@ describe('HasteModuleLoader', function() {
return buildLoader().then(function(loader) {
expect(function() {
loader.requireModule(null, 'DoesntExist');
}).toThrow('Cannot find module \'DoesntExist\' from \'.\'');
}).toThrow(new Error('Cannot find module \'DoesntExist\' from \'.\''));
});
});

Expand Down Expand Up @@ -90,9 +90,9 @@ describe('HasteModuleLoader', function() {
return buildLoader().then(function(loader) {
expect(function() {
loader.requireModule(__filename, './DoesntExist');
}).toThrow(
}).toThrow(new Error(
'Cannot find module \'./DoesntExist\' from \'' + __filename + '\''
);
));
});
});

Expand Down
204 changes: 0 additions & 204 deletions src/jasmine2TestRunner/JasmineReporter.js

This file was deleted.

89 changes: 89 additions & 0 deletions src/jasmineTestRunner/Jasmine2Reporter.js
@@ -0,0 +1,89 @@
/**
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';

var jasmineRequire = require('../../vendor/jasmine/jasmine-2.2.0');
var jasmine = jasmineRequire.core(jasmineRequire);
var Q = require('q');
var JasmineFormatter = require('./jasmineFormatter');

function Jasmine2Reporter(config) {
this._config = config || {};
this._formatter = new JasmineFormatter(jasmine, config);
this._resultsDeferred = Q.defer();
this._testResults = [];
this._currentSuites = [];
}

Jasmine2Reporter.prototype.specDone = function(result) {
this._testResults.push(this._extractSpecResults(result,
this._currentSuites.slice(0)));
};

Jasmine2Reporter.prototype.suiteStarted = function(suite) {
this._currentSuites.push(suite.description);
};

Jasmine2Reporter.prototype.suiteDone = function() {
this._currentSuites.pop();
};

Jasmine2Reporter.prototype.jasmineDone = function() {

var numFailingTests = 0;
var numPassingTests = 0;

this._testResults.forEach(function(testResult) {
if (testResult.failureMessages.length > 0) {
numFailingTests++;
} else {
numPassingTests++;
}
});

this._resultsDeferred.resolve({
numFailingTests: numFailingTests,
numPassingTests: numPassingTests,
testResults: this._testResults
});
};

Jasmine2Reporter.prototype.getResults = function() {
return this._resultsDeferred.promise;
};

Jasmine2Reporter.prototype._extractSpecResults =
function(specResult, currentSuites) {
var results = {
title: 'it ' + specResult.description,
ancestorTitles: currentSuites,
failureMessages: [],
logMessages: [], // Jasmine 2 does not have a logging interface
numPassingAsserts: 0 // Jasmine 2 only returns an array of failed asserts.
};

specResult.failedExpectations.forEach(function(failed) {
if (!failed.matcherName) { // exception

results.failureMessages.push(
this._formatter.formatException(failed.stack)
);

} else { // match failure

results.failureMessages.push(
this._formatter.formatMatchFailure(failed)
);

}
}.bind(this));

return results;
};

module.exports = Jasmine2Reporter;

0 comments on commit ebd2500

Please sign in to comment.