Omit irrelevant properties from suiteStarted
This commit is contained in:
@@ -916,7 +916,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
* same call stack height as the originals. This property may be removed in
|
* same call stack height as the originals. This property may be removed in
|
||||||
* a future version unless there is enough user interest in keeping it.
|
* a future version unless there is enough user interest in keeping it.
|
||||||
* See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
* See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
||||||
* @since 6.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
return this.#commonEventFields();
|
return this.#commonEventFields();
|
||||||
}
|
}
|
||||||
@@ -942,7 +942,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
* @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 {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||||
* @since 6.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
const event = {
|
const event = {
|
||||||
...this.#commonEventFields(),
|
...this.#commonEventFields(),
|
||||||
@@ -8766,7 +8766,7 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
|||||||
* `suiteStarted` is invoked when a `describe` starts to run
|
* `suiteStarted` is invoked when a `describe` starts to run
|
||||||
* @function
|
* @function
|
||||||
* @name Reporter#suiteStarted
|
* @name Reporter#suiteStarted
|
||||||
* @param {SuiteResult} result Information about the individual {@link describe} being run
|
* @param {SuiteStartedEvent} result Information about the individual {@link describe} being run
|
||||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||||
* @see async
|
* @see async
|
||||||
@@ -8778,7 +8778,7 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
|||||||
* While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`.
|
* While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`.
|
||||||
* @function
|
* @function
|
||||||
* @name Reporter#suiteDone
|
* @name Reporter#suiteDone
|
||||||
* @param {SuiteResult} result
|
* @param {SuiteDoneEvent} result
|
||||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||||
* @see async
|
* @see async
|
||||||
@@ -9617,7 +9617,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
|||||||
this.#currentRunableTracker.popSuite();
|
this.#currentRunableTracker.popSuite();
|
||||||
let overallStatus, incompleteReason, incompleteCode;
|
let overallStatus, incompleteReason, incompleteCode;
|
||||||
|
|
||||||
if (hasFailures || this.#topSuite.result.failedExpectations.length > 0) {
|
if (hasFailures || this.#topSuite.hasOwnFailedExpectations()) {
|
||||||
overallStatus = 'failed';
|
overallStatus = 'failed';
|
||||||
} else if (this.#getFocusedRunables().length > 0) {
|
} else if (this.#getFocusedRunables().length > 0) {
|
||||||
overallStatus = 'incomplete';
|
overallStatus = 'incomplete';
|
||||||
@@ -10711,8 +10711,45 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
this.result = {
|
||||||
|
id: this.id,
|
||||||
|
description: this.description,
|
||||||
|
fullName: this.getFullName(),
|
||||||
|
parentSuiteId: this.#reportedParentSuiteId,
|
||||||
|
filename: this.filename,
|
||||||
|
failedExpectations: [],
|
||||||
|
deprecationWarnings: [],
|
||||||
|
duration: null,
|
||||||
|
properties: null
|
||||||
|
};
|
||||||
|
this.markedPending = this.markedExcluding;
|
||||||
|
this.children.forEach(function(child) {
|
||||||
|
child.reset();
|
||||||
|
});
|
||||||
|
this.reportedDone = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
startedEvent() {
|
||||||
/**
|
/**
|
||||||
* @typedef SuiteResult
|
* @typedef SuiteStartedEvent
|
||||||
|
* @property {String} 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 {String|null} parentSuiteId - The ID of the suite containing this suite, or null if this is not in another describe().
|
||||||
|
* @property {String} filename - Deprecated. The name of the file the suite was defined in.
|
||||||
|
* Note: The value may be incorrect if zone.js is installed or
|
||||||
|
* `describe`/`fdescribe`/`xdescribe` have been replaced with versions that
|
||||||
|
* don't maintain the same call stack height as the originals. This property
|
||||||
|
* may be removed in a future version unless there is enough user interest
|
||||||
|
* in keeping it. See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
||||||
|
* @since 6.0.0
|
||||||
|
*/
|
||||||
|
return this.#commonEventFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
doneEvent() {
|
||||||
|
/**
|
||||||
|
* @typedef SuiteDoneEvent
|
||||||
* @property {String} id - The unique id of this suite.
|
* @property {String} id - The unique id of this suite.
|
||||||
* @property {String} description - The description text passed to the {@link describe} that made 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 {String} fullName - The full description including all ancestors of this suite.
|
||||||
@@ -10730,22 +10767,32 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
this.result = {
|
const event = {
|
||||||
|
...this.#commonEventFields(),
|
||||||
|
status: this.#status()
|
||||||
|
};
|
||||||
|
const toCopy = [
|
||||||
|
'failedExpectations',
|
||||||
|
'deprecationWarnings',
|
||||||
|
'duration',
|
||||||
|
'properties'
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const k of toCopy) {
|
||||||
|
event[k] = this.result[k];
|
||||||
|
}
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
#commonEventFields() {
|
||||||
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
fullName: this.getFullName(),
|
fullName: this.getFullName(),
|
||||||
parentSuiteId: this.#reportedParentSuiteId,
|
parentSuiteId: this.#reportedParentSuiteId,
|
||||||
filename: this.filename,
|
filename: this.filename
|
||||||
failedExpectations: [],
|
|
||||||
deprecationWarnings: [],
|
|
||||||
duration: null,
|
|
||||||
properties: null
|
|
||||||
};
|
};
|
||||||
this.markedPending = this.markedExcluding;
|
|
||||||
this.children.forEach(function(child) {
|
|
||||||
child.reset();
|
|
||||||
});
|
|
||||||
this.reportedDone = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeChildren() {
|
removeChildren() {
|
||||||
@@ -10768,6 +10815,10 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasOwnFailedExpectations() {
|
||||||
|
return this.result.failedExpectations.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
getResult() {
|
getResult() {
|
||||||
this.result.status = this.#status();
|
this.result.status = this.#status();
|
||||||
return this.result;
|
return this.result;
|
||||||
@@ -11713,7 +11764,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
|
|
||||||
this.#runQueue({
|
this.#runQueue({
|
||||||
onComplete: maybeError => {
|
onComplete: maybeError => {
|
||||||
this.#suiteSegmentComplete(suite, suite.getResult(), () => {
|
this.#suiteSegmentComplete(suite, () => {
|
||||||
done(maybeError);
|
done(maybeError);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -11750,11 +11801,13 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
#suiteSegmentStart(suite, next) {
|
#suiteSegmentStart(suite, next) {
|
||||||
this.#currentRunableTracker.pushSuite(suite);
|
this.#currentRunableTracker.pushSuite(suite);
|
||||||
this.#runableResources.initForRunable(suite.id, suite.parentSuite.id);
|
this.#runableResources.initForRunable(suite.id, suite.parentSuite.id);
|
||||||
this.#reportDispatcher.suiteStarted(suite.result).then(next);
|
this.#reportDispatcher.suiteStarted(suite.startedEvent()).then(next);
|
||||||
suite.startTimer();
|
suite.startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
#suiteSegmentComplete(suite, result, next) {
|
#suiteSegmentComplete(suite, next) {
|
||||||
|
suite.endTimer();
|
||||||
|
const result = suite.doneEvent();
|
||||||
const isTopSuite = suite === this.#executionTree.topSuite;
|
const isTopSuite = suite === this.#executionTree.topSuite;
|
||||||
|
|
||||||
if (!isTopSuite) {
|
if (!isTopSuite) {
|
||||||
@@ -11773,7 +11826,6 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
if (result.status === 'failed') {
|
if (result.status === 'failed') {
|
||||||
this.#hasFailures = true;
|
this.#hasFailures = true;
|
||||||
}
|
}
|
||||||
suite.endTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const finish = isTopSuite
|
const finish = isTopSuite
|
||||||
@@ -11811,14 +11863,14 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
async #reportChildrenOfBeforeAllFailure(suite) {
|
async #reportChildrenOfBeforeAllFailure(suite) {
|
||||||
for (const child of suite.children) {
|
for (const child of suite.children) {
|
||||||
if (child instanceof j$.private.Suite) {
|
if (child instanceof j$.private.Suite) {
|
||||||
await this.#reportDispatcher.suiteStarted(child.result);
|
await this.#reportDispatcher.suiteStarted(child.startedEvent());
|
||||||
await this.#reportChildrenOfBeforeAllFailure(child);
|
await this.#reportChildrenOfBeforeAllFailure(child);
|
||||||
|
|
||||||
// Marking the suite passed is consistent with how suites that
|
// Marking the suite passed is consistent with how suites that
|
||||||
// contain failed specs but no suite-level failures are reported.
|
// contain failed specs but no suite-level failures are reported.
|
||||||
child.result.status = 'passed';
|
child.result.status = 'passed';
|
||||||
|
|
||||||
await this.#reportDispatcher.suiteDone(child.result);
|
await this.#reportDispatcher.suiteDone(child.doneEvent());
|
||||||
} else {
|
} else {
|
||||||
/* a spec */
|
/* a spec */
|
||||||
await this.#reportDispatcher.specStarted(child.startedEvent());
|
await this.#reportDispatcher.specStarted(child.startedEvent());
|
||||||
|
|||||||
@@ -37,11 +37,16 @@ describe('Runner', function() {
|
|||||||
this.sharedUserContext = function() {
|
this.sharedUserContext = function() {
|
||||||
return attrs.userContext || {};
|
return attrs.userContext || {};
|
||||||
};
|
};
|
||||||
|
// TODO remove
|
||||||
this.result = {
|
this.result = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
failedExpectations: []
|
failedExpectations: []
|
||||||
};
|
};
|
||||||
this.getResult = jasmine.createSpy('getResult');
|
this.startedEvent = jasmine.createSpy('startedEvent');
|
||||||
|
this.doneEvent = jasmine.createSpy('doneEvent');
|
||||||
|
this.hasOwnFailedExpectations = jasmine.createSpy(
|
||||||
|
'hasOwnFailedExpectations'
|
||||||
|
);
|
||||||
this.beforeAllFns = attrs.beforeAllFns || [];
|
this.beforeAllFns = attrs.beforeAllFns || [];
|
||||||
this.afterAllFns = attrs.afterAllFns || [];
|
this.afterAllFns = attrs.afterAllFns || [];
|
||||||
this.cleanupBeforeAfter = function() {};
|
this.cleanupBeforeAfter = function() {};
|
||||||
@@ -182,10 +187,13 @@ describe('Runner', function() {
|
|||||||
SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy
|
SkipPolicy: privateUnderTest.SkipAfterBeforeAllErrorPolicy
|
||||||
});
|
});
|
||||||
|
|
||||||
|
suite.startedEvent.and.returnValue('suite started event');
|
||||||
runQueue.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
runQueue.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
||||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(suite.result);
|
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(
|
||||||
|
'suite started event'
|
||||||
|
);
|
||||||
|
|
||||||
suite.getResult.and.returnValue({ my: 'result' });
|
suite.doneEvent.and.returnValue({ my: 'result' });
|
||||||
|
|
||||||
runQueue.calls.mostRecent().args[0].onComplete();
|
runQueue.calls.mostRecent().args[0].onComplete();
|
||||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith({ my: 'result' });
|
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith({ my: 'result' });
|
||||||
@@ -233,12 +241,15 @@ describe('Runner', function() {
|
|||||||
queueableFns = runQueue.calls.mostRecent().args[0].queueableFns;
|
queueableFns = runQueue.calls.mostRecent().args[0].queueableFns;
|
||||||
expect(queueableFns.length).toBe(2);
|
expect(queueableFns.length).toBe(2);
|
||||||
|
|
||||||
|
parent.startedEvent.and.returnValue('parent suite started event');
|
||||||
queueableFns[0].fn();
|
queueableFns[0].fn();
|
||||||
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(parent.result);
|
expect(reportDispatcher.suiteStarted).toHaveBeenCalledWith(
|
||||||
|
'parent suite started event'
|
||||||
|
);
|
||||||
|
|
||||||
verifyAndFinishSpec(spec, queueableFns[1], true);
|
verifyAndFinishSpec(spec, queueableFns[1], true);
|
||||||
|
|
||||||
parent.getResult.and.returnValue(parent.result);
|
parent.doneEvent.and.returnValue(parent.result);
|
||||||
runQueue.calls.argsFor(1)[0].onComplete();
|
runQueue.calls.argsFor(1)[0].onComplete();
|
||||||
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(parent.result);
|
expect(reportDispatcher.suiteDone).toHaveBeenCalledWith(parent.result);
|
||||||
await expectAsync(promise).toBePending();
|
await expectAsync(promise).toBePending();
|
||||||
|
|||||||
@@ -425,4 +425,34 @@ describe('Suite', function() {
|
|||||||
}).toThrowError("Value can't be cloned");
|
}).toThrowError("Value can't be cloned");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#startedEvent', function() {
|
||||||
|
it('includes only properties that are known before execution', function() {
|
||||||
|
const topSuite = new privateUnderTest.Suite({});
|
||||||
|
const parentSuite = new privateUnderTest.Suite({
|
||||||
|
id: 'suite1',
|
||||||
|
parentSuite: topSuite,
|
||||||
|
description: 'a parent suite'
|
||||||
|
});
|
||||||
|
const suite = new privateUnderTest.Suite({
|
||||||
|
id: 'suite2',
|
||||||
|
parentSuite,
|
||||||
|
reportedParentSuiteId: parentSuite.id,
|
||||||
|
description: 'a suite',
|
||||||
|
filename: 'somefile.js',
|
||||||
|
getPath() {
|
||||||
|
return ['a parent suite', 'a spec'];
|
||||||
|
},
|
||||||
|
queueableFn: { fn: () => {} }
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(suite.startedEvent()).toEqual({
|
||||||
|
id: 'suite2',
|
||||||
|
parentSuiteId: 'suite1',
|
||||||
|
description: 'a suite',
|
||||||
|
fullName: 'a parent suite a suite',
|
||||||
|
filename: 'somefile.js'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1765,10 +1765,12 @@ describe('Env integration', function() {
|
|||||||
|
|
||||||
const baseSuiteEvent = {
|
const baseSuiteEvent = {
|
||||||
id: jasmine.any(String),
|
id: jasmine.any(String),
|
||||||
filename: jasmine.any(String),
|
filename: jasmine.any(String)
|
||||||
|
};
|
||||||
|
const baseSuiteDoneEvent = {
|
||||||
|
...baseSuiteEvent,
|
||||||
failedExpectations: [],
|
failedExpectations: [],
|
||||||
deprecationWarnings: [],
|
deprecationWarnings: [],
|
||||||
duration: null,
|
|
||||||
properties: null
|
properties: null
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1779,7 +1781,7 @@ describe('Env integration', function() {
|
|||||||
parentSuiteId: null
|
parentSuiteId: null
|
||||||
});
|
});
|
||||||
expect(reporter.suiteDone.calls.argsFor(2)[0]).toEqual({
|
expect(reporter.suiteDone.calls.argsFor(2)[0]).toEqual({
|
||||||
...baseSuiteEvent,
|
...baseSuiteDoneEvent,
|
||||||
description: 'A Suite',
|
description: 'A Suite',
|
||||||
fullName: 'A Suite',
|
fullName: 'A Suite',
|
||||||
status: 'passed',
|
status: 'passed',
|
||||||
@@ -1794,7 +1796,7 @@ describe('Env integration', function() {
|
|||||||
parentSuiteId: suiteFullNameToId['A Suite']
|
parentSuiteId: suiteFullNameToId['A Suite']
|
||||||
});
|
});
|
||||||
expect(reporter.suiteDone.calls.argsFor(0)[0]).toEqual({
|
expect(reporter.suiteDone.calls.argsFor(0)[0]).toEqual({
|
||||||
...baseSuiteEvent,
|
...baseSuiteDoneEvent,
|
||||||
description: 'with a nested suite',
|
description: 'with a nested suite',
|
||||||
status: 'passed',
|
status: 'passed',
|
||||||
fullName: 'A Suite with a nested suite',
|
fullName: 'A Suite with a nested suite',
|
||||||
@@ -1809,7 +1811,7 @@ describe('Env integration', function() {
|
|||||||
parentSuiteId: suiteFullNameToId['A Suite']
|
parentSuiteId: suiteFullNameToId['A Suite']
|
||||||
});
|
});
|
||||||
expect(reporter.suiteDone.calls.argsFor(1)[0]).toEqual({
|
expect(reporter.suiteDone.calls.argsFor(1)[0]).toEqual({
|
||||||
...baseSuiteEvent,
|
...baseSuiteDoneEvent,
|
||||||
description: 'with only non-executable specs',
|
description: 'with only non-executable specs',
|
||||||
status: 'passed',
|
status: 'passed',
|
||||||
fullName: 'A Suite with only non-executable specs',
|
fullName: 'A Suite with only non-executable specs',
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ getJasmineRequireObj().Runner = function(j$) {
|
|||||||
this.#currentRunableTracker.popSuite();
|
this.#currentRunableTracker.popSuite();
|
||||||
let overallStatus, incompleteReason, incompleteCode;
|
let overallStatus, incompleteReason, incompleteCode;
|
||||||
|
|
||||||
if (hasFailures || this.#topSuite.result.failedExpectations.length > 0) {
|
if (hasFailures || this.#topSuite.hasOwnFailedExpectations()) {
|
||||||
overallStatus = 'failed';
|
overallStatus = 'failed';
|
||||||
} else if (this.#getFocusedRunables().length > 0) {
|
} else if (this.#getFocusedRunables().length > 0) {
|
||||||
overallStatus = 'incomplete';
|
overallStatus = 'incomplete';
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
* same call stack height as the originals. This property may be removed in
|
* same call stack height as the originals. This property may be removed in
|
||||||
* a future version unless there is enough user interest in keeping it.
|
* a future version unless there is enough user interest in keeping it.
|
||||||
* See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
* See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
||||||
* @since 6.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
return this.#commonEventFields();
|
return this.#commonEventFields();
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
|||||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
* @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 {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||||
* @since 6.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
const event = {
|
const event = {
|
||||||
...this.#commonEventFields(),
|
...this.#commonEventFields(),
|
||||||
|
|||||||
@@ -100,8 +100,45 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
this.result = {
|
||||||
|
id: this.id,
|
||||||
|
description: this.description,
|
||||||
|
fullName: this.getFullName(),
|
||||||
|
parentSuiteId: this.#reportedParentSuiteId,
|
||||||
|
filename: this.filename,
|
||||||
|
failedExpectations: [],
|
||||||
|
deprecationWarnings: [],
|
||||||
|
duration: null,
|
||||||
|
properties: null
|
||||||
|
};
|
||||||
|
this.markedPending = this.markedExcluding;
|
||||||
|
this.children.forEach(function(child) {
|
||||||
|
child.reset();
|
||||||
|
});
|
||||||
|
this.reportedDone = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
startedEvent() {
|
||||||
/**
|
/**
|
||||||
* @typedef SuiteResult
|
* @typedef SuiteStartedEvent
|
||||||
|
* @property {String} 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 {String|null} parentSuiteId - The ID of the suite containing this suite, or null if this is not in another describe().
|
||||||
|
* @property {String} filename - Deprecated. The name of the file the suite was defined in.
|
||||||
|
* Note: The value may be incorrect if zone.js is installed or
|
||||||
|
* `describe`/`fdescribe`/`xdescribe` have been replaced with versions that
|
||||||
|
* don't maintain the same call stack height as the originals. This property
|
||||||
|
* may be removed in a future version unless there is enough user interest
|
||||||
|
* in keeping it. See {@link https://github.com/jasmine/jasmine/issues/2065}.
|
||||||
|
* @since 6.0.0
|
||||||
|
*/
|
||||||
|
return this.#commonEventFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
doneEvent() {
|
||||||
|
/**
|
||||||
|
* @typedef SuiteDoneEvent
|
||||||
* @property {String} id - The unique id of this suite.
|
* @property {String} id - The unique id of this suite.
|
||||||
* @property {String} description - The description text passed to the {@link describe} that made 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 {String} fullName - The full description including all ancestors of this suite.
|
||||||
@@ -119,22 +156,32 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSuiteProperty}
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
this.result = {
|
const event = {
|
||||||
|
...this.#commonEventFields(),
|
||||||
|
status: this.#status()
|
||||||
|
};
|
||||||
|
const toCopy = [
|
||||||
|
'failedExpectations',
|
||||||
|
'deprecationWarnings',
|
||||||
|
'duration',
|
||||||
|
'properties'
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const k of toCopy) {
|
||||||
|
event[k] = this.result[k];
|
||||||
|
}
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
#commonEventFields() {
|
||||||
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
fullName: this.getFullName(),
|
fullName: this.getFullName(),
|
||||||
parentSuiteId: this.#reportedParentSuiteId,
|
parentSuiteId: this.#reportedParentSuiteId,
|
||||||
filename: this.filename,
|
filename: this.filename
|
||||||
failedExpectations: [],
|
|
||||||
deprecationWarnings: [],
|
|
||||||
duration: null,
|
|
||||||
properties: null
|
|
||||||
};
|
};
|
||||||
this.markedPending = this.markedExcluding;
|
|
||||||
this.children.forEach(function(child) {
|
|
||||||
child.reset();
|
|
||||||
});
|
|
||||||
this.reportedDone = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeChildren() {
|
removeChildren() {
|
||||||
@@ -157,6 +204,10 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasOwnFailedExpectations() {
|
||||||
|
return this.result.failedExpectations.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
getResult() {
|
getResult() {
|
||||||
this.result.status = this.#status();
|
this.result.status = this.#status();
|
||||||
return this.result;
|
return this.result;
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
|
|
||||||
this.#runQueue({
|
this.#runQueue({
|
||||||
onComplete: maybeError => {
|
onComplete: maybeError => {
|
||||||
this.#suiteSegmentComplete(suite, suite.getResult(), () => {
|
this.#suiteSegmentComplete(suite, () => {
|
||||||
done(maybeError);
|
done(maybeError);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -200,11 +200,12 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
#suiteSegmentStart(suite, next) {
|
#suiteSegmentStart(suite, next) {
|
||||||
this.#currentRunableTracker.pushSuite(suite);
|
this.#currentRunableTracker.pushSuite(suite);
|
||||||
this.#runableResources.initForRunable(suite.id, suite.parentSuite.id);
|
this.#runableResources.initForRunable(suite.id, suite.parentSuite.id);
|
||||||
this.#reportDispatcher.suiteStarted(suite.result).then(next);
|
this.#reportDispatcher.suiteStarted(suite.startedEvent()).then(next);
|
||||||
suite.startTimer();
|
suite.startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
#suiteSegmentComplete(suite, result, next) {
|
#suiteSegmentComplete(suite, next) {
|
||||||
|
suite.endTimer();
|
||||||
const isTopSuite = suite === this.#executionTree.topSuite;
|
const isTopSuite = suite === this.#executionTree.topSuite;
|
||||||
|
|
||||||
if (!isTopSuite) {
|
if (!isTopSuite) {
|
||||||
@@ -220,15 +221,14 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
this.#runableResources.clearForRunable(suite.id);
|
this.#runableResources.clearForRunable(suite.id);
|
||||||
this.#currentRunableTracker.popSuite();
|
this.#currentRunableTracker.popSuite();
|
||||||
|
|
||||||
if (result.status === 'failed') {
|
if (suite.doneEvent().status === 'failed') {
|
||||||
this.#hasFailures = true;
|
this.#hasFailures = true;
|
||||||
}
|
}
|
||||||
suite.endTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const finish = isTopSuite
|
const finish = isTopSuite
|
||||||
? next
|
? next
|
||||||
: () => this.#reportSuiteDone(suite, result, next);
|
: () => this.#reportSuiteDone(suite, next);
|
||||||
|
|
||||||
if (suite.hadBeforeAllFailure) {
|
if (suite.hadBeforeAllFailure) {
|
||||||
this.#reportChildrenOfBeforeAllFailure(suite).then(finish);
|
this.#reportChildrenOfBeforeAllFailure(suite).then(finish);
|
||||||
@@ -237,9 +237,9 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#reportSuiteDone(suite, result, next) {
|
#reportSuiteDone(suite, next) {
|
||||||
suite.reportedDone = true;
|
suite.reportedDone = true;
|
||||||
this.#reportDispatcher.suiteDone(result).then(next);
|
this.#reportDispatcher.suiteDone(suite.doneEvent()).then(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #specComplete(spec) {
|
async #specComplete(spec) {
|
||||||
@@ -261,14 +261,14 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
|||||||
async #reportChildrenOfBeforeAllFailure(suite) {
|
async #reportChildrenOfBeforeAllFailure(suite) {
|
||||||
for (const child of suite.children) {
|
for (const child of suite.children) {
|
||||||
if (child instanceof j$.private.Suite) {
|
if (child instanceof j$.private.Suite) {
|
||||||
await this.#reportDispatcher.suiteStarted(child.result);
|
await this.#reportDispatcher.suiteStarted(child.startedEvent());
|
||||||
await this.#reportChildrenOfBeforeAllFailure(child);
|
await this.#reportChildrenOfBeforeAllFailure(child);
|
||||||
|
|
||||||
// Marking the suite passed is consistent with how suites that
|
// Marking the suite passed is consistent with how suites that
|
||||||
// contain failed specs but no suite-level failures are reported.
|
// contain failed specs but no suite-level failures are reported.
|
||||||
child.result.status = 'passed';
|
child.result.status = 'passed';
|
||||||
|
|
||||||
await this.#reportDispatcher.suiteDone(child.result);
|
await this.#reportDispatcher.suiteDone(child.doneEvent());
|
||||||
} else {
|
} else {
|
||||||
/* a spec */
|
/* a spec */
|
||||||
await this.#reportDispatcher.specStarted(child.startedEvent());
|
await this.#reportDispatcher.specStarted(child.startedEvent());
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
|||||||
* `suiteStarted` is invoked when a `describe` starts to run
|
* `suiteStarted` is invoked when a `describe` starts to run
|
||||||
* @function
|
* @function
|
||||||
* @name Reporter#suiteStarted
|
* @name Reporter#suiteStarted
|
||||||
* @param {SuiteResult} result Information about the individual {@link describe} being run
|
* @param {SuiteStartedEvent} result Information about the individual {@link describe} being run
|
||||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||||
* @see async
|
* @see async
|
||||||
@@ -62,7 +62,7 @@ getJasmineRequireObj().reporterEvents = function(j$) {
|
|||||||
* While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`.
|
* While jasmine doesn't require any specific functions, not defining a `suiteDone` will make it impossible for a reporter to know when a suite has failures in an `afterAll`.
|
||||||
* @function
|
* @function
|
||||||
* @name Reporter#suiteDone
|
* @name Reporter#suiteDone
|
||||||
* @param {SuiteResult} result
|
* @param {SuiteDoneEvent} result
|
||||||
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
* @param {Function} [done] Used to specify to Jasmine that this callback is asynchronous and Jasmine should wait until it has been called before moving on.
|
||||||
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
* @returns {} Optionally return a Promise instead of using `done` to cause Jasmine to wait for completion.
|
||||||
* @see async
|
* @see async
|
||||||
|
|||||||
Reference in New Issue
Block a user