Renamed the trace feature to debugLog[s]

"trace" was ambiguous and could easily be understood to have something
to do with stack traces.
This commit is contained in:
Steve Gravrock
2021-12-02 14:46:56 -08:00
parent 5eb42d67a7
commit 40fac8b6a2
12 changed files with 97 additions and 117 deletions

View File

@@ -1190,14 +1190,14 @@ getJasmineRequireObj().Env = function(j$) {
currentSuite().setSuiteProperty(key, value);
};
this.trace = function(msg) {
this.debugLog = function(msg) {
var maybeSpec = currentRunnable();
if (!maybeSpec || !maybeSpec.trace) {
throw new Error("'trace' was called when there was no current spec");
if (!maybeSpec || !maybeSpec.debugLog) {
throw new Error("'debugLog' was called when there was no current spec");
}
maybeSpec.trace(msg);
maybeSpec.debugLog(msg);
};
this.expect = function(actual) {

View File

@@ -71,7 +71,7 @@ getJasmineRequireObj().Spec = function(j$) {
* @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}
* @property {TraceEntry[]|null} trace - Trace messages, if any, that were logged using {@link jasmine.trace} during a failing spec.
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
* @since 2.0.0
*/
this.result = {
@@ -84,7 +84,7 @@ getJasmineRequireObj().Spec = function(j$) {
pendingReason: '',
duration: null,
properties: null,
trace: null
debugLogs: null
};
}
@@ -133,7 +133,7 @@ getJasmineRequireObj().Spec = function(j$) {
self.result.duration = self.timer.elapsed();
if (self.result.status !== 'failed') {
self.result.trace = null;
self.result.debugLogs = null;
}
self.resultCallback(self.result, done);
@@ -184,21 +184,6 @@ getJasmineRequireObj().Spec = function(j$) {
};
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}
* @property {TraceEntry[]|null} trace - Trace messages, if any, that were logged using {@link Env#trace} during a failing spec.
* @since 2.0.0
*/
this.result = {
id: this.id,
description: this.description,
@@ -209,7 +194,7 @@ getJasmineRequireObj().Spec = function(j$) {
pendingReason: this.excludeMessage,
duration: null,
properties: null,
trace: null
debugLogs: null
};
this.markedPending = this.markedExcluding;
};
@@ -308,18 +293,21 @@ getJasmineRequireObj().Spec = function(j$) {
);
};
Spec.prototype.trace = function(msg) {
if (!this.result.trace) {
this.result.trace = [];
Spec.prototype.debugLog = function(msg) {
if (!this.result.debugLogs) {
this.result.debugLogs = [];
}
/**
* @typedef TraceEntry
* @property {String} message - The message that was passed to {@link jasmine.trace}.
* @typedef DebugLogEntry
* @property {String} message - The message that was passed to {@link jasmine.debugLog}.
* @property {number} timestamp - The time when the entry was added, in
* milliseconds from the spec's start time
*/
this.result.trace.push({ message: msg, timestamp: this.timer.elapsed() });
this.result.debugLogs.push({
message: msg,
timestamp: this.timer.elapsed()
});
};
var extractCustomPendingMessage = function(e) {

View File

@@ -406,11 +406,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
* This method should be called only when a spec (including any associated
* beforeEach or afterEach functions) is running.
* @function
* @name jasmine.trace
* @since 3.10.0
* @name jasmine.debugLog
* @since 4.0.0
* @param {String} msg - The message to log
*/
j$.trace = function(msg) {
j$.getEnv().trace(msg);
j$.debugLog = function(msg) {
j$.getEnv().debugLog(msg);
};
};