HtmlReporterV2: replace dots with progress bar
This commit is contained in:
@@ -618,9 +618,11 @@ jasmineRequire.Banner = function(j$) {
|
||||
|
||||
class Banner {
|
||||
#navigateWithNewParam;
|
||||
#omitHideDisabled;
|
||||
|
||||
constructor(navigateWithNewParam) {
|
||||
constructor(navigateWithNewParam, omitHideDisabled) {
|
||||
this.#navigateWithNewParam = navigateWithNewParam;
|
||||
this.#omitHideDisabled = omitHideDisabled;
|
||||
this.rootEl = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-banner' },
|
||||
@@ -638,55 +640,53 @@ jasmineRequire.Banner = function(j$) {
|
||||
}
|
||||
|
||||
#optionsMenu(config) {
|
||||
const optionsMenuDom = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-run-options' },
|
||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||
const items = [
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-payload' },
|
||||
{ className: 'jasmine-stop-on-failure' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-fail-fast',
|
||||
id: 'jasmine-fail-fast',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-stop-on-failure' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-fail-fast',
|
||||
id: 'jasmine-fail-fast',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-fail-fast' },
|
||||
'stop execution on spec failure'
|
||||
)
|
||||
),
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-fail-fast' },
|
||||
'stop execution on spec failure'
|
||||
)
|
||||
),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-throw-failures' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-throw',
|
||||
id: 'jasmine-throw-failures',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-throw-failures' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-throw',
|
||||
id: 'jasmine-throw-failures',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-throw-failures' },
|
||||
'stop spec on expectation failure'
|
||||
)
|
||||
),
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-throw-failures' },
|
||||
'stop spec on expectation failure'
|
||||
)
|
||||
),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-random-order' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-random',
|
||||
id: 'jasmine-random-order',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-random-order' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-random',
|
||||
id: 'jasmine-random-order',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-random-order' },
|
||||
'run tests in random order'
|
||||
)
|
||||
),
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-random-order' },
|
||||
'run tests in random order'
|
||||
)
|
||||
)
|
||||
];
|
||||
|
||||
if (!this.#omitHideDisabled) {
|
||||
items.push(
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-hide-disabled' },
|
||||
@@ -701,7 +701,14 @@ jasmineRequire.Banner = function(j$) {
|
||||
'hide disabled tests'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const optionsMenuDom = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-run-options' },
|
||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||
createDom('div', { className: 'jasmine-payload' }, items)
|
||||
);
|
||||
|
||||
const failFastCheckbox = optionsMenuDom.querySelector(
|
||||
@@ -734,14 +741,16 @@ jasmineRequire.Banner = function(j$) {
|
||||
this.#navigateWithNewParam('random', !config.random);
|
||||
};
|
||||
|
||||
const hideDisabled = optionsMenuDom.querySelector(
|
||||
'#jasmine-hide-disabled'
|
||||
);
|
||||
hideDisabled.checked = config.hideDisabled;
|
||||
// TODO: backfill tests for this!
|
||||
hideDisabled.onclick = () => {
|
||||
this.#navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||
};
|
||||
if (!this.#omitHideDisabled) {
|
||||
const hideDisabled = optionsMenuDom.querySelector(
|
||||
'#jasmine-hide-disabled'
|
||||
);
|
||||
hideDisabled.checked = config.hideDisabled;
|
||||
// TODO: backfill tests for this!
|
||||
hideDisabled.onclick = () => {
|
||||
this.#navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||
};
|
||||
}
|
||||
|
||||
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||
optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
|
||||
@@ -1004,7 +1013,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
// Sub-views
|
||||
#alerts;
|
||||
#symbols;
|
||||
#progress;
|
||||
#banner;
|
||||
#failures;
|
||||
|
||||
@@ -1038,16 +1047,17 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
this.#stateBuilder = new j$.private.ResultsStateBuilder();
|
||||
|
||||
this.#alerts = new j$.private.AlertsView(this.#urlBuilder);
|
||||
this.#symbols = new j$.private.SymbolsView();
|
||||
this.#progress = new ProgressView();
|
||||
this.#banner = new j$.private.Banner(
|
||||
this.#queryString.navigateWithNewParam.bind(this.#queryString)
|
||||
this.#queryString.navigateWithNewParam.bind(this.#queryString),
|
||||
true
|
||||
);
|
||||
this.#failures = new j$.private.FailuresView(this.#urlBuilder);
|
||||
this.#htmlReporterMain = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine_html-reporter' },
|
||||
this.#banner.rootEl,
|
||||
this.#symbols.rootEl,
|
||||
this.#progress.rootEl,
|
||||
this.#alerts.rootEl,
|
||||
this.#failures.rootEl
|
||||
);
|
||||
@@ -1056,6 +1066,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
jasmineStarted(options) {
|
||||
this.#stateBuilder.jasmineStarted(options);
|
||||
this.#progress.start(options.totalSpecsDefined);
|
||||
}
|
||||
|
||||
suiteStarted(result) {
|
||||
@@ -1072,7 +1083,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
specDone(result) {
|
||||
this.#stateBuilder.specDone(result);
|
||||
this.#symbols.append(result, this.#config);
|
||||
this.#progress.specDone(result, this.#config);
|
||||
|
||||
if (noExpectations(result)) {
|
||||
const noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
|
||||
@@ -1092,6 +1103,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
jasmineDone(doneResult) {
|
||||
this.#stateBuilder.jasmineDone(doneResult);
|
||||
this.#progress.rootEl.style.visibility = 'hidden';
|
||||
this.#alerts.addDuration(doneResult.totalTime);
|
||||
this.#banner.showOptionsMenu(this.#config);
|
||||
|
||||
@@ -1157,6 +1169,25 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
}
|
||||
}
|
||||
|
||||
class ProgressView {
|
||||
constructor() {
|
||||
this.rootEl = createDom('progress', { value: 0 });
|
||||
}
|
||||
|
||||
start(totalSpecsDefined) {
|
||||
this.rootEl.max = totalSpecsDefined;
|
||||
}
|
||||
|
||||
specDone(result) {
|
||||
this.rootEl.value = this.rootEl.value + 1;
|
||||
|
||||
if (result.status === 'failed') {
|
||||
// TODO: also a non-color indicator
|
||||
this.rootEl.classList.add('failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class UrlBuilder {
|
||||
#queryString;
|
||||
#getSuiteById;
|
||||
@@ -1237,8 +1268,7 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) {
|
||||
stopOnSpecFailure: this.queryString.getParam('stopOnSpecFailure'),
|
||||
stopSpecOnExpectationFailure: this.queryString.getParam(
|
||||
'stopSpecOnExpectationFailure'
|
||||
),
|
||||
hideDisabled: this.queryString.getParam('hideDisabled')
|
||||
)
|
||||
};
|
||||
|
||||
const random = this.queryString.getParam('random');
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
@charset "UTF-8";
|
||||
progress {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
progress[value] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
progress[value]::-webkit-progress-value, progress[value]::-moz-progress-bar {
|
||||
background: #007069;
|
||||
}
|
||||
.failed progress[value]::-webkit-progress-value, .failed progress[value]::-moz-progress-bar {
|
||||
background: #ca3a11;
|
||||
}
|
||||
|
||||
progress.failed[value]::-webkit-progress-value, progress.failed[value]::-moz-progress-bar {
|
||||
background: #ca3a11;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
@@ -3452,6 +3452,8 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
specFilter: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
// TODO: remove hideDisabled when HtmlReporter is removed
|
||||
/**
|
||||
* Whether reporters should hide disabled specs from their output.
|
||||
* Currently only supported by Jasmine's HTMLReporter
|
||||
@@ -3459,6 +3461,7 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
* @since 3.3.0
|
||||
* @type Boolean
|
||||
* @default false
|
||||
* @deprecated
|
||||
*/
|
||||
hideDisabled: false,
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('HtmlReporterV2', function() {
|
||||
expect(container.querySelector('div.jasmine-alert')).toBeTruthy();
|
||||
expect(container.querySelector('div.jasmine-results')).toBeTruthy();
|
||||
|
||||
expect(container.querySelector('ul.jasmine-symbol-summary')).toBeTruthy();
|
||||
expect(container.querySelector('progress')).toBeTruthy();
|
||||
|
||||
// title banner
|
||||
const banner = container.querySelector('.jasmine-banner');
|
||||
@@ -72,7 +72,7 @@ describe('HtmlReporterV2', function() {
|
||||
reporter.initialize();
|
||||
});
|
||||
|
||||
it('should log warning to the console and print a special symbol when empty spec status is passed', function() {
|
||||
it('logs a warning to the console when the spec passed', function() {
|
||||
reporter.specDone({
|
||||
status: 'passed',
|
||||
fullName: 'Some Name',
|
||||
@@ -83,11 +83,9 @@ describe('HtmlReporterV2', function() {
|
||||
expect(console.warn).toHaveBeenCalledWith(
|
||||
"Spec 'Some Name' has no expectations."
|
||||
);
|
||||
const specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||
expect(specEl.getAttribute('class')).toEqual('jasmine-empty');
|
||||
});
|
||||
|
||||
it('should log error to the console and print a failure symbol when empty spec status is failed', function() {
|
||||
it('logs an error to the console when the spec failed', function() {
|
||||
reporter.specDone({
|
||||
status: 'failed',
|
||||
fullName: 'Some Name',
|
||||
@@ -98,64 +96,32 @@ describe('HtmlReporterV2', function() {
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
"Spec 'Some Name' has no expectations."
|
||||
);
|
||||
const specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||
expect(specEl.getAttribute('class')).toEqual('jasmine-failed');
|
||||
});
|
||||
});
|
||||
|
||||
it('reports the status symbol of a excluded spec', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
reporter.specDone({
|
||||
id: 789,
|
||||
status: 'excluded',
|
||||
fullName: 'symbols should have titles',
|
||||
passedExpectations: [],
|
||||
failedExpectations: []
|
||||
});
|
||||
|
||||
const specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||
expect(specEl.getAttribute('class')).toEqual('jasmine-excluded');
|
||||
expect(specEl.getAttribute('id')).toEqual('spec_789');
|
||||
expect(specEl.getAttribute('title')).toEqual(
|
||||
'symbols should have titles'
|
||||
);
|
||||
});
|
||||
|
||||
it('reports the status symbol of a pending spec', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({
|
||||
id: 789,
|
||||
status: 'pending',
|
||||
passedExpectations: [],
|
||||
failedExpectations: []
|
||||
});
|
||||
|
||||
const specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||
expect(specEl.getAttribute('class')).toEqual('jasmine-pending');
|
||||
expect(specEl.getAttribute('id')).toEqual('spec_789');
|
||||
});
|
||||
|
||||
it('reports the status symbol of a passing spec', function() {
|
||||
it('updates the progress bar', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
const progress = container.querySelector('progress');
|
||||
|
||||
reporter.specDone({
|
||||
id: 123,
|
||||
status: 'passed',
|
||||
passedExpectations: [{ passed: true }],
|
||||
failedExpectations: []
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
});
|
||||
expect(progress.getAttribute('value')).toEqual('1');
|
||||
|
||||
const statuses = container.querySelector('.jasmine-symbol-summary');
|
||||
const specEl = statuses.querySelector('li');
|
||||
expect(specEl.getAttribute('class')).toEqual('jasmine-passed');
|
||||
expect(specEl.getAttribute('id')).toEqual('spec_123');
|
||||
reporter.specDone({
|
||||
id: 345,
|
||||
status: 'passed',
|
||||
failedExpectations: [],
|
||||
passedExpectations: []
|
||||
});
|
||||
expect(progress.getAttribute('value')).toEqual('2');
|
||||
});
|
||||
|
||||
it('reports the status symbol of a failing spec', function() {
|
||||
it('changes the progress bar status if the spec failed', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
@@ -166,9 +132,8 @@ describe('HtmlReporterV2', function() {
|
||||
passedExpectations: []
|
||||
});
|
||||
|
||||
const specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||
expect(specEl.getAttribute('class')).toEqual('jasmine-failed');
|
||||
expect(specEl.getAttribute('id')).toEqual('spec_345');
|
||||
const progress = container.querySelector('progress');
|
||||
expect(progress).toHaveClass('failed');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -177,7 +142,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.specDone({
|
||||
status: 'passed',
|
||||
fullName: 'a spec with a deprecation',
|
||||
@@ -218,7 +183,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
deprecationWarnings: [
|
||||
{
|
||||
@@ -254,7 +219,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
deprecationWarnings: [
|
||||
{
|
||||
@@ -273,7 +238,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
deprecationWarnings: [
|
||||
{
|
||||
@@ -298,7 +263,7 @@ describe('HtmlReporterV2', function() {
|
||||
spyOn(console, 'error');
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.suiteStarted({ id: 1 });
|
||||
reporter.specDone({
|
||||
id: 1,
|
||||
@@ -322,7 +287,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
|
||||
reporter.jasmineDone({ totalTime: 100 });
|
||||
|
||||
@@ -340,7 +305,7 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.suiteStarted({
|
||||
id: 1,
|
||||
description: 'A Suite',
|
||||
@@ -471,7 +436,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
failedExpectations: [
|
||||
{
|
||||
@@ -503,7 +468,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
failedExpectations: [
|
||||
{ message: 'load error', globalErrorType: 'load' },
|
||||
@@ -533,7 +498,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
failedExpectations: [
|
||||
{
|
||||
@@ -658,46 +623,6 @@ describe('HtmlReporterV2', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('UI for hiding disabled specs', function() {
|
||||
it('should be unchecked if not hiding disabled specs', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ hideDisabled: false });
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const disabledUI = container.querySelector('.jasmine-disabled');
|
||||
expect(disabledUI.checked).toBe(false);
|
||||
});
|
||||
|
||||
it('should be checked if hiding disabled', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ hideDisabled: true });
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
const disabledUI = container.querySelector('.jasmine-disabled');
|
||||
expect(disabledUI.checked).toBe(true);
|
||||
});
|
||||
|
||||
it('should not display specs that have been disabled', function() {
|
||||
const reporter = setup();
|
||||
env.configure({ hideDisabled: true });
|
||||
reporter.initialize();
|
||||
reporter.specDone({
|
||||
id: 789,
|
||||
status: 'excluded',
|
||||
fullName: 'symbols should have titles',
|
||||
passedExpectations: [],
|
||||
failedExpectations: []
|
||||
});
|
||||
|
||||
const specEl = container.querySelector('.jasmine-symbol-summary li');
|
||||
expect(specEl.getAttribute('class')).toEqual(
|
||||
'jasmine-excluded-no-display'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('UI for running tests in random order', function() {
|
||||
it('should be unchecked if not randomizing', function() {
|
||||
const reporter = setup();
|
||||
@@ -1194,7 +1119,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
overallStatus: 'passed',
|
||||
failedExpectations: []
|
||||
@@ -1210,7 +1135,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
overallStatus: 'failed',
|
||||
failedExpectations: []
|
||||
@@ -1226,7 +1151,7 @@ describe('HtmlReporterV2', function() {
|
||||
const reporter = setup();
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
||||
reporter.jasmineDone({
|
||||
overallStatus: 'incomplete',
|
||||
incompleteReason: 'because nope',
|
||||
|
||||
@@ -2,7 +2,6 @@ describe('HtmlReporterV2Urls', function() {
|
||||
describe('#configFromCurrentUrl', function() {
|
||||
passesThroughQueryParam('stopOnSpecFailure');
|
||||
passesThroughQueryParam('stopSpecOnExpectationFailure');
|
||||
passesThroughQueryParam('hideDisabled');
|
||||
passesThroughQueryParam('random');
|
||||
ignoresEmpty('random');
|
||||
passesThroughQueryParam('seed');
|
||||
|
||||
@@ -73,6 +73,8 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
specFilter: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
// TODO: remove hideDisabled when HtmlReporter is removed
|
||||
/**
|
||||
* Whether reporters should hide disabled specs from their output.
|
||||
* Currently only supported by Jasmine's HTMLReporter
|
||||
@@ -80,6 +82,7 @@ getJasmineRequireObj().Configuration = function(j$) {
|
||||
* @since 3.3.0
|
||||
* @type Boolean
|
||||
* @default false
|
||||
* @deprecated
|
||||
*/
|
||||
hideDisabled: false,
|
||||
/**
|
||||
|
||||
@@ -5,9 +5,11 @@ jasmineRequire.Banner = function(j$) {
|
||||
|
||||
class Banner {
|
||||
#navigateWithNewParam;
|
||||
#omitHideDisabled;
|
||||
|
||||
constructor(navigateWithNewParam) {
|
||||
constructor(navigateWithNewParam, omitHideDisabled) {
|
||||
this.#navigateWithNewParam = navigateWithNewParam;
|
||||
this.#omitHideDisabled = omitHideDisabled;
|
||||
this.rootEl = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-banner' },
|
||||
@@ -25,55 +27,53 @@ jasmineRequire.Banner = function(j$) {
|
||||
}
|
||||
|
||||
#optionsMenu(config) {
|
||||
const optionsMenuDom = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-run-options' },
|
||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||
const items = [
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-payload' },
|
||||
{ className: 'jasmine-stop-on-failure' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-fail-fast',
|
||||
id: 'jasmine-fail-fast',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-stop-on-failure' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-fail-fast',
|
||||
id: 'jasmine-fail-fast',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-fail-fast' },
|
||||
'stop execution on spec failure'
|
||||
)
|
||||
),
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-fail-fast' },
|
||||
'stop execution on spec failure'
|
||||
)
|
||||
),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-throw-failures' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-throw',
|
||||
id: 'jasmine-throw-failures',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-throw-failures' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-throw',
|
||||
id: 'jasmine-throw-failures',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-throw-failures' },
|
||||
'stop spec on expectation failure'
|
||||
)
|
||||
),
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-throw-failures' },
|
||||
'stop spec on expectation failure'
|
||||
)
|
||||
),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-random-order' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-random',
|
||||
id: 'jasmine-random-order',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-random-order' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-random',
|
||||
id: 'jasmine-random-order',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-random-order' },
|
||||
'run tests in random order'
|
||||
)
|
||||
),
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-random-order' },
|
||||
'run tests in random order'
|
||||
)
|
||||
)
|
||||
];
|
||||
|
||||
if (!this.#omitHideDisabled) {
|
||||
items.push(
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-hide-disabled' },
|
||||
@@ -88,7 +88,14 @@ jasmineRequire.Banner = function(j$) {
|
||||
'hide disabled tests'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const optionsMenuDom = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-run-options' },
|
||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||
createDom('div', { className: 'jasmine-payload' }, items)
|
||||
);
|
||||
|
||||
const failFastCheckbox = optionsMenuDom.querySelector(
|
||||
@@ -121,14 +128,16 @@ jasmineRequire.Banner = function(j$) {
|
||||
this.#navigateWithNewParam('random', !config.random);
|
||||
};
|
||||
|
||||
const hideDisabled = optionsMenuDom.querySelector(
|
||||
'#jasmine-hide-disabled'
|
||||
);
|
||||
hideDisabled.checked = config.hideDisabled;
|
||||
// TODO: backfill tests for this!
|
||||
hideDisabled.onclick = () => {
|
||||
this.#navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||
};
|
||||
if (!this.#omitHideDisabled) {
|
||||
const hideDisabled = optionsMenuDom.querySelector(
|
||||
'#jasmine-hide-disabled'
|
||||
);
|
||||
hideDisabled.checked = config.hideDisabled;
|
||||
// TODO: backfill tests for this!
|
||||
hideDisabled.onclick = () => {
|
||||
this.#navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||
};
|
||||
}
|
||||
|
||||
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||
optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
|
||||
|
||||
@@ -22,7 +22,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
// Sub-views
|
||||
#alerts;
|
||||
#symbols;
|
||||
#progress;
|
||||
#banner;
|
||||
#failures;
|
||||
|
||||
@@ -56,16 +56,17 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
this.#stateBuilder = new j$.private.ResultsStateBuilder();
|
||||
|
||||
this.#alerts = new j$.private.AlertsView(this.#urlBuilder);
|
||||
this.#symbols = new j$.private.SymbolsView();
|
||||
this.#progress = new ProgressView();
|
||||
this.#banner = new j$.private.Banner(
|
||||
this.#queryString.navigateWithNewParam.bind(this.#queryString)
|
||||
this.#queryString.navigateWithNewParam.bind(this.#queryString),
|
||||
true
|
||||
);
|
||||
this.#failures = new j$.private.FailuresView(this.#urlBuilder);
|
||||
this.#htmlReporterMain = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine_html-reporter' },
|
||||
this.#banner.rootEl,
|
||||
this.#symbols.rootEl,
|
||||
this.#progress.rootEl,
|
||||
this.#alerts.rootEl,
|
||||
this.#failures.rootEl
|
||||
);
|
||||
@@ -74,6 +75,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
jasmineStarted(options) {
|
||||
this.#stateBuilder.jasmineStarted(options);
|
||||
this.#progress.start(options.totalSpecsDefined);
|
||||
}
|
||||
|
||||
suiteStarted(result) {
|
||||
@@ -90,7 +92,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
specDone(result) {
|
||||
this.#stateBuilder.specDone(result);
|
||||
this.#symbols.append(result, this.#config);
|
||||
this.#progress.specDone(result, this.#config);
|
||||
|
||||
if (noExpectations(result)) {
|
||||
const noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
|
||||
@@ -110,6 +112,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
|
||||
jasmineDone(doneResult) {
|
||||
this.#stateBuilder.jasmineDone(doneResult);
|
||||
this.#progress.rootEl.style.visibility = 'hidden';
|
||||
this.#alerts.addDuration(doneResult.totalTime);
|
||||
this.#banner.showOptionsMenu(this.#config);
|
||||
|
||||
@@ -175,6 +178,25 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
}
|
||||
}
|
||||
|
||||
class ProgressView {
|
||||
constructor() {
|
||||
this.rootEl = createDom('progress', { value: 0 });
|
||||
}
|
||||
|
||||
start(totalSpecsDefined) {
|
||||
this.rootEl.max = totalSpecsDefined;
|
||||
}
|
||||
|
||||
specDone(result) {
|
||||
this.rootEl.value = this.rootEl.value + 1;
|
||||
|
||||
if (result.status === 'failed') {
|
||||
// TODO: also a non-color indicator
|
||||
this.rootEl.classList.add('failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class UrlBuilder {
|
||||
#queryString;
|
||||
#getSuiteById;
|
||||
|
||||
@@ -22,8 +22,7 @@ jasmineRequire.HtmlReporterV2Urls = function(j$) {
|
||||
stopOnSpecFailure: this.queryString.getParam('stopOnSpecFailure'),
|
||||
stopSpecOnExpectationFailure: this.queryString.getParam(
|
||||
'stopSpecOnExpectationFailure'
|
||||
),
|
||||
hideDisabled: this.queryString.getParam('hideDisabled')
|
||||
)
|
||||
};
|
||||
|
||||
const random = this.queryString.getParam('random');
|
||||
|
||||
@@ -26,6 +26,26 @@ $space: "\0020";
|
||||
$font-size: 11px;
|
||||
$large-font-size: 14px;
|
||||
|
||||
// TODO: nope
|
||||
progress {
|
||||
width: 100%;
|
||||
}
|
||||
progress[value] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
progress[value]::-webkit-progress-value, progress[value]::-moz-progress-bar {
|
||||
background: $passing-color;
|
||||
|
||||
.failed & {
|
||||
background: $failing-color;
|
||||
}
|
||||
}
|
||||
progress.failed[value]::-webkit-progress-value, progress.failed[value]::-moz-progress-bar {
|
||||
background: $failing-color;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user