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
+14 -12
View File
@@ -234,7 +234,7 @@ describe('Spec', function() {
pendingReason: '',
duration: jasmine.any(Number),
properties: null,
trace: null
debugLogs: null
},
'things'
);
@@ -562,13 +562,15 @@ describe('Spec', function() {
t2 = 456;
spec.execute();
expect(spec.result.trace).toBeNull();
expect(spec.result.debugLogs).toBeNull();
timer.elapsed.and.returnValue(t1);
spec.trace('msg 1');
expect(spec.result.trace).toEqual([{ message: 'msg 1', timestamp: t1 }]);
spec.debugLog('msg 1');
expect(spec.result.debugLogs).toEqual([
{ message: 'msg 1', timestamp: t1 }
]);
timer.elapsed.and.returnValue(t2);
spec.trace('msg 2');
expect(spec.result.trace).toEqual([
spec.debugLog('msg 2');
expect(spec.result.debugLogs).toEqual([
{ message: 'msg 1', timestamp: t1 },
{ message: 'msg 2', timestamp: t2 }
]);
@@ -583,7 +585,7 @@ describe('Spec', function() {
},
resultCallback: resultCallback,
queueRunnerFactory: function(config) {
spec.trace('msg');
spec.debugLog('msg');
for (const fn of config.queueableFns) {
fn.fn();
}
@@ -593,7 +595,7 @@ describe('Spec', function() {
spec.execute(function() {});
expect(resultCallback).toHaveBeenCalledWith(
jasmine.objectContaining({ trace: null }),
jasmine.objectContaining({ debugLogs: null }),
undefined
);
});
@@ -606,7 +608,7 @@ describe('Spec', function() {
},
resultCallback: resultCallback,
queueRunnerFactory: function(config) {
spec.trace('msg');
spec.debugLog('msg');
for (const fn of config.queueableFns) {
fn.fn();
}
@@ -616,7 +618,7 @@ describe('Spec', function() {
spec.execute(function() {});
expect(resultCallback).toHaveBeenCalled();
expect(spec.result.trace).toBeNull();
expect(spec.result.debugLogs).toBeNull();
});
});
@@ -630,7 +632,7 @@ describe('Spec', function() {
},
resultCallback: resultCallback,
queueRunnerFactory: function(config) {
spec.trace('msg');
spec.debugLog('msg');
spec.onException(new Error('nope'));
for (const fn of config.queueableFns) {
fn.fn();
@@ -646,7 +648,7 @@ describe('Spec', function() {
spec.execute(function() {});
expect(resultCallback).toHaveBeenCalledWith(
jasmine.objectContaining({
trace: [{ message: 'msg', timestamp: timestamp }]
debugLogs: [{ message: 'msg', timestamp: timestamp }]
}),
undefined
);
+7 -5
View File
@@ -199,11 +199,13 @@ describe('base helpers', function() {
});
});
describe('trace', function() {
it("forwards to the current env's trace function", function() {
spyOn(jasmineUnderTest.getEnv(), 'trace');
jasmineUnderTest.trace('a message');
expect(jasmineUnderTest.getEnv().trace).toHaveBeenCalledWith('a message');
describe('debugLog', function() {
it("forwards to the current env's debugLog function", function() {
spyOn(jasmineUnderTest.getEnv(), 'debugLog');
jasmineUnderTest.debugLog('a message');
expect(jasmineUnderTest.getEnv().debugLog).toHaveBeenCalledWith(
'a message'
);
});
});
});
+9 -9
View File
@@ -3335,7 +3335,7 @@ describe('Env integration', function() {
});
});
it('sends traces to the reporter when the spec fails', function(done) {
it('sends debug logs to the reporter when the spec fails', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']),
startTime,
endTime;
@@ -3345,14 +3345,14 @@ describe('Env integration', function() {
env.it('fails', function() {
startTime = new Date().getTime();
env.trace('message 1');
env.trace('message 2');
env.debugLog('message 1');
env.debugLog('message 2');
env.expect(1).toBe(2);
endTime = new Date().getTime();
});
env.it('passes', function() {
env.trace('message that should not be reported');
env.debugLog('message that should not be reported');
});
env.execute(null, function() {
@@ -3373,7 +3373,7 @@ describe('Env integration', function() {
duration = reporter.specDone.calls.argsFor(0)[0].duration;
expect(reporter.specDone.calls.argsFor(0)[0]).toEqual(
jasmine.objectContaining({
trace: [
debugLogs: [
{
timestamp: numberInRange(0, duration),
message: 'message 1'
@@ -3385,17 +3385,17 @@ describe('Env integration', function() {
]
})
);
expect(reporter.specDone.calls.argsFor(1)[0].trace).toBeFalsy();
expect(reporter.specDone.calls.argsFor(1)[0].debugLogs).toBeFalsy();
done();
});
});
it('reports an error when trace is used when a spec is not running', function(done) {
it('reports an error when debugLog is used when a spec is not running', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['suiteDone']);
env.describe('a suite', function() {
env.beforeAll(function() {
env.trace('a message');
env.debugLog('a message');
});
env.it('a spec', function() {});
@@ -3408,7 +3408,7 @@ describe('Env integration', function() {
failedExpectations: [
jasmine.objectContaining({
message: jasmine.stringContaining(
"'trace' was called when there was no current spec"
"'debugLog' was called when there was no current spec"
)
})
]