Added the ability to associate trace information with failing specs

This is meant to aid in debugging failures, particularly intermittent
failures, in cases where interactive debugging or console.log aren't
suitable.
This commit is contained in:
Steve Gravrock
2021-09-25 16:07:33 -07:00
parent ef981bb794
commit 7a289f1de7
12 changed files with 447 additions and 7 deletions

View File

@@ -1339,6 +1339,23 @@ describe('HtmlReporter', function() {
}
]
};
var failingSpecResultWithTrace = {
id: 567,
status: 'failed',
description: 'a failing spec',
fullName: 'a suite inner suite a failing spec',
passedExpectations: [],
failedExpectations: [
{
message: 'a failure message',
stack: 'a stack trace'
}
],
trace: [
{ timestamp: 123, message: 'msg 1' },
{ timestamp: 456, message: 'msg 1' }
]
};
var passingSuiteResult = {
id: 1,
@@ -1356,18 +1373,20 @@ describe('HtmlReporter', function() {
reporter.suiteDone(passingSuiteResult);
reporter.suiteDone(failingSuiteResult);
reporter.suiteDone(passingSuiteResult);
reporter.specStarted(failingSpecResultWithTrace);
reporter.specDone(failingSpecResultWithTrace);
reporter.jasmineDone({});
});
it('reports the specs counts', function() {
var alertBar = container.querySelector('.jasmine-alert .jasmine-bar');
expect(alertBar.innerHTML).toMatch(/2 specs, 2 failure/);
expect(alertBar.innerHTML).toMatch(/3 specs, 3 failures/);
});
it('reports failure messages and stack traces', function() {
var specFailures = container.querySelector('.jasmine-failures');
expect(specFailures.childNodes.length).toEqual(2);
expect(specFailures.childNodes.length).toEqual(3);
var specFailure = specFailures.childNodes[0];
expect(specFailure.getAttribute('class')).toMatch(/jasmine-failed/);
@@ -1408,6 +1427,18 @@ describe('HtmlReporter', function() {
expect(suiteStackTrace.innerHTML).toEqual('a stack trace');
});
it('reports traces when present', function() {
var specFailure = container.querySelectorAll(
'.jasmine-spec-detail.jasmine-failed'
)[2],
trace = specFailure.querySelector('.jasmine-trace table'),
rows;
expect(trace).toBeTruthy();
rows = trace.querySelectorAll('tbody tr');
expect(rows.length).toEqual(2);
});
it('provides links to focus on a failure and each containing suite', function() {
var description = container.querySelector(
'.jasmine-failures .jasmine-description'