Merge branch '3.99' into 4.0
This commit is contained in:
@@ -122,6 +122,15 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* property and always create native promises instead.
|
||||
*/
|
||||
Promise: undefined,
|
||||
/**
|
||||
* Clean closures when a suite is done running (done by clearing the stored function reference).
|
||||
* This prevents memory leaks, but you won't be able to run jasmine multiple times.
|
||||
* @name Configuration#autoCleanClosures
|
||||
* @since 3.10.0
|
||||
* @type boolean
|
||||
* @default true
|
||||
*/
|
||||
autoCleanClosures: true,
|
||||
/**
|
||||
* Whether or not to issue warnings for certain deprecated functionality
|
||||
* every time it's used. If not set or set to false, deprecation warnings
|
||||
@@ -188,7 +197,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
'failSpecWithNoExpectations',
|
||||
'hideDisabled',
|
||||
'stopOnSpecFailure',
|
||||
'stopSpecOnExpectationFailure'
|
||||
'stopSpecOnExpectationFailure',
|
||||
'autoCleanClosures'
|
||||
];
|
||||
|
||||
booleanProps.forEach(function(prop) {
|
||||
@@ -435,10 +445,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
delete runnableResources[id];
|
||||
};
|
||||
|
||||
var beforeAndAfterFns = function(suite) {
|
||||
var beforeAndAfterFns = function(targetSuite) {
|
||||
return function() {
|
||||
var befores = [],
|
||||
afters = [];
|
||||
afters = [],
|
||||
suite = targetSuite;
|
||||
|
||||
while (suite) {
|
||||
befores = befores.concat(suite.beforeFns);
|
||||
@@ -540,10 +551,10 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
expectationFactory: expectationFactory,
|
||||
asyncExpectationFactory: suiteAsyncExpectationFactory,
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
autoCleanClosures: config.autoCleanClosures,
|
||||
onLateError: recordLateError
|
||||
});
|
||||
var deprecator = new j$.Deprecator(topSuite);
|
||||
defaultResourcesForRunnable(topSuite.id);
|
||||
currentDeclarationSuite = topSuite;
|
||||
|
||||
/**
|
||||
@@ -662,6 +673,11 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
* @return {Promise<undefined>}
|
||||
*/
|
||||
this.execute = function(runnablesToRun, onComplete) {
|
||||
if (this._executedBefore) {
|
||||
topSuite.reset();
|
||||
}
|
||||
this._executedBefore = true;
|
||||
defaultResourcesForRunnable(topSuite.id);
|
||||
installGlobalErrors();
|
||||
|
||||
if (!runnablesToRun) {
|
||||
@@ -935,6 +951,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
asyncExpectationFactory: suiteAsyncExpectationFactory,
|
||||
expectationResultFactory: expectationResultFactory,
|
||||
throwOnExpectationFailure: config.stopSpecOnExpectationFailure,
|
||||
autoCleanClosures: config.autoCleanClosures,
|
||||
onLateError: recordLateError
|
||||
});
|
||||
|
||||
@@ -948,8 +965,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
if (specDefinitions.length > 0) {
|
||||
throw new Error('describe does not expect any arguments');
|
||||
}
|
||||
if (currentDeclarationSuite.markedPending) {
|
||||
suite.pend();
|
||||
if (currentDeclarationSuite.markedExcluding) {
|
||||
suite.exclude();
|
||||
}
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
if (suite.parentSuite && !suite.children.length) {
|
||||
@@ -962,7 +979,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
ensureIsNotNested('xdescribe');
|
||||
ensureIsFunction(specDefinitions, 'xdescribe');
|
||||
var suite = suiteFactory(description);
|
||||
suite.pend();
|
||||
suite.exclude();
|
||||
addSpecsToSuite(suite, specDefinitions);
|
||||
return suite.metadata;
|
||||
};
|
||||
@@ -1048,6 +1065,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
timeout: timeout || 0
|
||||
},
|
||||
throwOnExpectationFailure: config.stopSpecOnExpectationFailure,
|
||||
autoCleanClosures: config.autoCleanClosures,
|
||||
timer: new j$.Timer()
|
||||
});
|
||||
return spec;
|
||||
@@ -1083,8 +1101,8 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
|
||||
var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
|
||||
if (currentDeclarationSuite.markedPending) {
|
||||
spec.pend();
|
||||
if (currentDeclarationSuite.markedExcluding) {
|
||||
spec.exclude();
|
||||
}
|
||||
currentDeclarationSuite.addChild(spec);
|
||||
|
||||
@@ -1104,7 +1122,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
ensureIsFunctionOrAsync(fn, 'xit');
|
||||
}
|
||||
var spec = this.it_.apply(this, arguments);
|
||||
spec.pend('Temporarily disabled with xit');
|
||||
spec.exclude('Temporarily disabled with xit');
|
||||
return spec.metadata;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return {};
|
||||
};
|
||||
this.onStart = attrs.onStart || function() {};
|
||||
this.autoCleanClosures =
|
||||
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
||||
this.getSpecName =
|
||||
attrs.getSpecName ||
|
||||
function() {
|
||||
@@ -54,7 +56,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.timer = attrs.timer || new j$.Timer();
|
||||
|
||||
if (!this.queueableFn.fn) {
|
||||
this.pend();
|
||||
this.exclude();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +126,9 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
|
||||
var complete = {
|
||||
fn: function(done) {
|
||||
self.queueableFn.fn = null;
|
||||
if (self.autoCleanClosures) {
|
||||
self.queueableFn.fn = null;
|
||||
}
|
||||
self.result.status = self.status(excluded, failSpecWithNoExp);
|
||||
self.result.duration = self.timer.elapsed();
|
||||
|
||||
@@ -181,6 +185,36 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.queueRunnerFactory(runnerConfig);
|
||||
};
|
||||
|
||||
Spec.prototype.reset = function() {
|
||||
/**
|
||||
* @typedef SpecResult
|
||||
* @property {Int} id - The unique id of this spec.
|
||||
* @property {String} description - The description passed to the {@link it} that created this spec.
|
||||
* @property {String} fullName - The full description including all ancestors of this spec.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
||||
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: this.excludeMessage,
|
||||
duration: null,
|
||||
properties: null,
|
||||
trace: null
|
||||
};
|
||||
this.markedPending = this.markedExcluding;
|
||||
};
|
||||
|
||||
Spec.prototype.onException = function onException(e) {
|
||||
if (Spec.isPendingSpecException(e)) {
|
||||
this.pend(extractCustomPendingMessage(e));
|
||||
@@ -204,6 +238,10 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
);
|
||||
};
|
||||
|
||||
/*
|
||||
* Marks state as pending
|
||||
* @param {string} [message] An optional reason message
|
||||
*/
|
||||
Spec.prototype.pend = function(message) {
|
||||
this.markedPending = true;
|
||||
if (message) {
|
||||
@@ -211,6 +249,19 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Like {@link Spec#pend}, but pending state will survive {@link Spec#reset}
|
||||
* Useful for fit, xit, where pending state remains.
|
||||
* @param {string} [message] An optional reason message
|
||||
*/
|
||||
Spec.prototype.exclude = function(message) {
|
||||
this.markedExcluding = true;
|
||||
if (this.message) {
|
||||
this.excludeMessage = message;
|
||||
}
|
||||
this.pend();
|
||||
};
|
||||
|
||||
Spec.prototype.getResult = function() {
|
||||
this.result.status = this.status();
|
||||
return this.result;
|
||||
|
||||
@@ -27,6 +27,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||
this.expectationResultFactory = attrs.expectationResultFactory;
|
||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||
this.autoCleanClosures =
|
||||
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
||||
this.onLateError = attrs.onLateError;
|
||||
|
||||
this.beforeFns = [];
|
||||
@@ -43,27 +45,7 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
*/
|
||||
this.children = [];
|
||||
|
||||
/**
|
||||
* @typedef SuiteResult
|
||||
* @property {Int} id - The unique id of this suite.
|
||||
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
||||
* @property {String} fullName - The full description including all ancestors of this suite.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
||||
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
||||
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
properties: null
|
||||
};
|
||||
this.reset();
|
||||
}
|
||||
|
||||
Suite.prototype.setSuiteProperty = function(key, value) {
|
||||
@@ -100,10 +82,22 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
return fullName.join(' ');
|
||||
};
|
||||
|
||||
/*
|
||||
* Mark the suite with "pending" status
|
||||
*/
|
||||
Suite.prototype.pend = function() {
|
||||
this.markedPending = true;
|
||||
};
|
||||
|
||||
/*
|
||||
* Like {@link Suite#pend}, but pending state will survive {@link Spec#reset}
|
||||
* Useful for fdescribe, xdescribe, where pending state should remain.
|
||||
*/
|
||||
Suite.prototype.exclude = function() {
|
||||
this.pend();
|
||||
this.markedExcluding = true;
|
||||
};
|
||||
|
||||
Suite.prototype.beforeEach = function(fn) {
|
||||
this.beforeFns.unshift({ ...fn, suite: this });
|
||||
};
|
||||
@@ -135,10 +129,40 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
}
|
||||
|
||||
Suite.prototype.cleanupBeforeAfter = function() {
|
||||
removeFns(this.beforeAllFns);
|
||||
removeFns(this.afterAllFns);
|
||||
removeFns(this.beforeFns);
|
||||
removeFns(this.afterFns);
|
||||
if (this.autoCleanClosures) {
|
||||
removeFns(this.beforeAllFns);
|
||||
removeFns(this.afterAllFns);
|
||||
removeFns(this.beforeFns);
|
||||
removeFns(this.afterFns);
|
||||
}
|
||||
};
|
||||
|
||||
Suite.prototype.reset = function() {
|
||||
/**
|
||||
* @typedef SuiteResult
|
||||
* @property {Int} id - The unique id of this suite.
|
||||
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
||||
* @property {String} fullName - The full description including all ancestors of this suite.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
||||
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
||||
* @property {number} duration - The time in ms for Suite execution, including any before/afterAll, before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
properties: null
|
||||
};
|
||||
this.markedPending = this.markedExcluding;
|
||||
this.children.forEach(function(child) {
|
||||
child.reset();
|
||||
});
|
||||
};
|
||||
|
||||
Suite.prototype.addChild = function(child) {
|
||||
|
||||
Reference in New Issue
Block a user