Merge branch 'main' into 3.99

This commit is contained in:
Steve Gravrock
2021-04-22 17:23:08 -07:00
24 changed files with 504 additions and 100 deletions

View File

@@ -49,6 +49,18 @@ getJasmineRequireObj().CallTracker = function(j$) {
return call ? call.args : [];
};
/**
* Get the "this" object that was passed to a specific invocation of this spy.
* @name Spy#calls#thisFor
* @function
* @param {Integer} index The 0-based invocation index.
* @return {Object?}
*/
this.thisFor = function(index) {
var call = calls[index];
return call ? call.object : undefined;
};
/**
* Get the raw calls array for this spy.
* @name Spy#calls#all

View File

@@ -708,6 +708,13 @@ getJasmineRequireObj().Env = function(j$) {
defaultResourcesForRunnable(topSuite.id);
currentDeclarationSuite = topSuite;
/**
* Provides the root suite, through which all suites and specs can be
* accessed.
* @function
* @name Env#topSuite
* @return {Suite} the root suite
*/
this.topSuite = function() {
return topSuite;
};

View File

@@ -17,7 +17,22 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
this.jasmineHandlers = {};
this.installOne_ = function installOne_(errorType, jasmineMessage) {
function taggedOnError(error) {
error.jasmineMessage = jasmineMessage + ': ' + error;
var substituteMsg;
if (error) {
error.jasmineMessage = jasmineMessage + ': ' + error;
} else {
substituteMsg = jasmineMessage + ' with no error or message';
if (errorType === 'unhandledRejection') {
substituteMsg +=
'\n' +
'(Tip: to get a useful stack trace, use ' +
'Promise.reject(new Error(...)) instead of Promise.reject().)';
}
error = new Error(substituteMsg);
}
var handler = handlers[handlers.length - 1];

View File

@@ -1,8 +1,24 @@
getJasmineRequireObj().Suite = function(j$) {
/**
* @interface Suite
* @see Env#topSuite
*/
function Suite(attrs) {
this.env = attrs.env;
this.id = attrs.id;
/**
* The parent of this suite, or null if this is the top suite.
* @name Suite#parentSuite
* @readonly
* @type {Suite}
*/
this.parentSuite = attrs.parentSuite;
/**
* The description passed to the {@link describe} that created this suite.
* @name Suite#description
* @readonly
* @type {string}
*/
this.description = attrs.description;
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
@@ -16,6 +32,11 @@ getJasmineRequireObj().Suite = function(j$) {
this.timer = attrs.timer || new j$.Timer();
/**
* The suite's children.
* @name Suite#children
* @type {Array.<(Spec|Suite)>}
*/
this.children = [];
/**
@@ -53,6 +74,12 @@ getJasmineRequireObj().Suite = function(j$) {
return this.asyncExpectationFactory(actual, this);
};
/**
* The full description including all ancestors of this suite.
* @name Suite#getFullName
* @function
* @returns {string}
*/
Suite.prototype.getFullName = function() {
var fullName = [];
for (