Merge branch '5.99' into 6.0
This commit is contained in:
@@ -40,12 +40,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
(function() {
|
(function() {
|
||||||
const env = jasmine.getEnv();
|
const env = jasmine.getEnv();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ## Runner Parameters
|
||||||
|
*
|
||||||
|
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
||||||
|
*/
|
||||||
|
|
||||||
const queryString = new jasmine.QueryString({
|
const queryString = new jasmine.QueryString({
|
||||||
getWindowLocation: function() {
|
getWindowLocation: function() {
|
||||||
return window.location;
|
return window.location;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const filterSpecs = !!queryString.getParam('spec');
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
|
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
|
||||||
stopSpecOnExpectationFailure: queryString.getParam(
|
stopSpecOnExpectationFailure: queryString.getParam(
|
||||||
@@ -87,7 +95,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
return document.createTextNode.apply(document, arguments);
|
return document.createTextNode.apply(document, arguments);
|
||||||
},
|
},
|
||||||
timer: new jasmine.Timer(),
|
timer: new jasmine.Timer(),
|
||||||
queryString
|
filterSpecs: filterSpecs
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +107,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
/**
|
/**
|
||||||
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
||||||
*/
|
*/
|
||||||
const specFilter = new jasmine.HtmlExactSpecFilter({ queryString });
|
const specFilter = new jasmine.HtmlSpecFilter({
|
||||||
|
filterString: function() {
|
||||||
|
return queryString.getParam('spec');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
config.specFilter = function(spec) {
|
config.specFilter = function(spec) {
|
||||||
return specFilter.matches(spec);
|
return specFilter.matches(spec.getFullName());
|
||||||
};
|
};
|
||||||
|
|
||||||
env.configure(config);
|
env.configure(config);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ jasmineRequire.html = function(j$) {
|
|||||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||||
j$.QueryString = jasmineRequire.QueryString();
|
j$.QueryString = jasmineRequire.QueryString();
|
||||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||||
j$.HtmlExactSpecFilter = jasmineRequire.HtmlExactSpecFilter();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmineRequire.HtmlReporter = function(j$) {
|
jasmineRequire.HtmlReporter = function(j$) {
|
||||||
@@ -42,13 +41,11 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
this.specsExecuted = 0;
|
this.specsExecuted = 0;
|
||||||
this.failureCount = 0;
|
this.failureCount = 0;
|
||||||
this.pendingSpecCount = 0;
|
this.pendingSpecCount = 0;
|
||||||
this.suitesById = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultsStateBuilder.prototype.suiteStarted = function(result) {
|
ResultsStateBuilder.prototype.suiteStarted = function(result) {
|
||||||
this.currentParent.addChild(result, 'suite');
|
this.currentParent.addChild(result, 'suite');
|
||||||
this.currentParent = this.currentParent.last();
|
this.currentParent = this.currentParent.last();
|
||||||
this.suitesById[result.id] = this.currentParent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ResultsStateBuilder.prototype.suiteDone = function(result) {
|
ResultsStateBuilder.prototype.suiteDone = function(result) {
|
||||||
@@ -101,14 +98,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
const getContainer = options.getContainer;
|
const getContainer = options.getContainer;
|
||||||
const createElement = options.createElement;
|
const createElement = options.createElement;
|
||||||
const createTextNode = options.createTextNode;
|
const createTextNode = options.createTextNode;
|
||||||
// TODO: in the next major release, replace navigateWithNewParam and
|
|
||||||
// addToExistingQueryString with direct usage of options.queryString
|
|
||||||
const navigateWithNewParam = options.navigateWithNewParam || function() {};
|
const navigateWithNewParam = options.navigateWithNewParam || function() {};
|
||||||
const addToExistingQueryString =
|
const addToExistingQueryString =
|
||||||
options.addToExistingQueryString || defaultQueryString;
|
options.addToExistingQueryString || defaultQueryString;
|
||||||
const filterSpecs = options.queryString
|
const filterSpecs = options.filterSpecs;
|
||||||
? !!options.queryString.getParam('spec')
|
|
||||||
: options.filterSpecs; // For compatibility with pre-5.11 boot files
|
|
||||||
let htmlReporterMain;
|
let htmlReporterMain;
|
||||||
let symbols;
|
let symbols;
|
||||||
const deprecationWarnings = [];
|
const deprecationWarnings = [];
|
||||||
@@ -737,6 +730,21 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function suiteHref(suite) {
|
||||||
|
const els = [];
|
||||||
|
|
||||||
|
while (suite && suite.parent) {
|
||||||
|
els.unshift(suite.result.description);
|
||||||
|
suite = suite.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
|
||||||
|
return (
|
||||||
|
(window.location.pathname || '') +
|
||||||
|
addToExistingQueryString('spec', els.join(' '))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function addDeprecationWarnings(result, runnableType) {
|
function addDeprecationWarnings(result, runnableType) {
|
||||||
if (result && result.deprecationWarnings) {
|
if (result && result.deprecationWarnings) {
|
||||||
for (let i = 0; i < result.deprecationWarnings.length; i++) {
|
for (let i = 0; i < result.deprecationWarnings.length; i++) {
|
||||||
@@ -834,33 +842,11 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
return '' + count + ' ' + word;
|
return '' + count + ' ' + word;
|
||||||
}
|
}
|
||||||
|
|
||||||
function suitePath(suite) {
|
|
||||||
const els = [];
|
|
||||||
|
|
||||||
while (suite && suite.parent) {
|
|
||||||
els.unshift(suite.result.description);
|
|
||||||
suite = suite.parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return els;
|
|
||||||
}
|
|
||||||
|
|
||||||
function suiteHref(suite) {
|
|
||||||
return pathHref(suitePath(suite));
|
|
||||||
}
|
|
||||||
|
|
||||||
function specHref(result) {
|
function specHref(result) {
|
||||||
const suite = stateBuilder.suitesById[result.parentSuiteId];
|
|
||||||
const path = suitePath(suite);
|
|
||||||
path.push(result.description);
|
|
||||||
return pathHref(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pathHref(path) {
|
|
||||||
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
|
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
|
||||||
return (
|
return (
|
||||||
(window.location.pathname || '') +
|
(window.location.pathname || '') +
|
||||||
addToExistingQueryString('spec', JSON.stringify(path))
|
addToExistingQueryString('spec', result.fullName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,27 +897,11 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
jasmineRequire.HtmlSpecFilter = function() {
|
jasmineRequire.HtmlSpecFilter = function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
|
||||||
* @name HtmlSpecFilter
|
|
||||||
* @classdesc Legacy HTML spec filter, for backward compatibility
|
|
||||||
* with boot files that predate {@link HtmlExactSpecFilter}.
|
|
||||||
* @param options Object with a filterString method
|
|
||||||
* @constructor
|
|
||||||
* @deprecated
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
// Legacy HTML spec filter, preserved for backward compatibility with
|
|
||||||
// boot files that predate HtmlExactSpecFilterV2
|
|
||||||
function HtmlSpecFilter(options) {
|
function HtmlSpecFilter(options) {
|
||||||
let filterString = (options && options.filterString()) || '';
|
const filterString =
|
||||||
|
options &&
|
||||||
if (filterString.startsWith('[')) {
|
options.filterString() &&
|
||||||
// Convert an HtmlExactSpecFilterV2 string into something we can use
|
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||||
filterString = JSON.parse(filterString).join(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
filterString = filterString.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
||||||
|
|
||||||
const filterPattern = new RegExp(filterString);
|
const filterPattern = new RegExp(filterString);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1060,58 +1030,3 @@ jasmineRequire.QueryString = function() {
|
|||||||
|
|
||||||
return QueryString;
|
return QueryString;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmineRequire.HtmlExactSpecFilter = function() {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spec filter for use with {@link HtmlReporter}
|
|
||||||
*
|
|
||||||
* See lib/jasmine-core/boot1.js for usage.
|
|
||||||
* @since 5.11.0
|
|
||||||
*/
|
|
||||||
class HtmlExactSpecFilter {
|
|
||||||
#getFilterString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a filter instance.
|
|
||||||
* @param options Object with a queryString property, which should be an
|
|
||||||
* instance of {@link QueryString}.
|
|
||||||
*/
|
|
||||||
constructor(options) {
|
|
||||||
this.#getFilterString = function() {
|
|
||||||
return options.queryString.getParam('spec');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the specified spec should be executed.
|
|
||||||
* @param {Spec} spec
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
matches(spec) {
|
|
||||||
const filterString = this.#getFilterString();
|
|
||||||
|
|
||||||
if (!filterString) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filterPath = JSON.parse(this.#getFilterString());
|
|
||||||
const specPath = spec.getPath();
|
|
||||||
|
|
||||||
if (filterPath.length > specPath.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < filterPath.length; i++) {
|
|
||||||
if (specPath[i] !== filterPath[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return HtmlExactSpecFilter;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ describe('The jasmine namespace', function() {
|
|||||||
// jasmine-html.js
|
// jasmine-html.js
|
||||||
result.add('HtmlReporter');
|
result.add('HtmlReporter');
|
||||||
result.add('HtmlSpecFilter');
|
result.add('HtmlSpecFilter');
|
||||||
result.add('HtmlExactSpecFilter');
|
|
||||||
result.add('QueryString');
|
result.add('QueryString');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
describe('HtmlExactSpecFilter', function() {
|
|
||||||
it('matches everything when no string is provided', function() {
|
|
||||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
|
||||||
queryString: {
|
|
||||||
getParam(name) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(specFilter.matches({})).toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('matches a spec with the exact same path', function() {
|
|
||||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
|
||||||
queryString: {
|
|
||||||
getParam(name) {
|
|
||||||
if (name === 'spec') {
|
|
||||||
return '["a","b","c"]';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('matches a spec whose path has the filter path as a prefix', function() {
|
|
||||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
|
||||||
queryString: {
|
|
||||||
getParam(name) {
|
|
||||||
if (name === 'spec') {
|
|
||||||
return '["a","b"]';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not match a spec with a different path', function() {
|
|
||||||
const specFilter = new jasmineUnderTest.HtmlExactSpecFilter({
|
|
||||||
queryString: {
|
|
||||||
getParam(name) {
|
|
||||||
if (name === 'spec') {
|
|
||||||
return '["a","b","c"]';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(specFilter.matches(stubSpec(['a', 'd', 'c']))).toBeFalse();
|
|
||||||
});
|
|
||||||
|
|
||||||
function stubSpec(path) {
|
|
||||||
return {
|
|
||||||
getPath() {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -528,7 +528,6 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
let specResult = {
|
let specResult = {
|
||||||
id: 123,
|
id: 123,
|
||||||
parentSuiteId: 1,
|
|
||||||
description: 'with a spec',
|
description: 'with a spec',
|
||||||
fullName: 'A Suite with a spec',
|
fullName: 'A Suite with a spec',
|
||||||
status: 'passed',
|
status: 'passed',
|
||||||
@@ -606,9 +605,7 @@ describe('HtmlReporter', function() {
|
|||||||
const suiteDetail = outerSuite.childNodes[0];
|
const suiteDetail = outerSuite.childNodes[0];
|
||||||
const suiteLink = suiteDetail.childNodes[0];
|
const suiteLink = suiteDetail.childNodes[0];
|
||||||
expect(suiteLink.innerHTML).toEqual('A Suite');
|
expect(suiteLink.innerHTML).toEqual('A Suite');
|
||||||
expect(suiteLink.getAttribute('href')).toEqual(
|
expect(suiteLink.getAttribute('href')).toEqual('/?foo=bar&spec=A Suite');
|
||||||
'/?foo=bar&spec=["A Suite"]'
|
|
||||||
);
|
|
||||||
|
|
||||||
const specs = outerSuite.childNodes[1];
|
const specs = outerSuite.childNodes[1];
|
||||||
const spec = specs.childNodes[0];
|
const spec = specs.childNodes[0];
|
||||||
@@ -618,7 +615,7 @@ describe('HtmlReporter', function() {
|
|||||||
const specLink = spec.childNodes[0];
|
const specLink = spec.childNodes[0];
|
||||||
expect(specLink.innerHTML).toEqual('with a spec');
|
expect(specLink.innerHTML).toEqual('with a spec');
|
||||||
expect(specLink.getAttribute('href')).toEqual(
|
expect(specLink.getAttribute('href')).toEqual(
|
||||||
'/?foo=bar&spec=["A Suite","with a spec"]'
|
'/?foo=bar&spec=A Suite with a spec'
|
||||||
);
|
);
|
||||||
|
|
||||||
const specDuration = spec.childNodes[1];
|
const specDuration = spec.childNodes[1];
|
||||||
@@ -1368,11 +1365,6 @@ describe('HtmlReporter', function() {
|
|||||||
},
|
},
|
||||||
createTextNode: function() {
|
createTextNode: function() {
|
||||||
return document.createTextNode.apply(document, arguments);
|
return document.createTextNode.apply(document, arguments);
|
||||||
},
|
|
||||||
queryString: {
|
|
||||||
getParam(name) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
specStatus = {
|
specStatus = {
|
||||||
@@ -1387,12 +1379,7 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe('when the specs are not filtered', function() {
|
describe('when the specs are not filtered', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
reporterConfig.queryString.getParam = function(name) {
|
reporterConfig.filterSpecs = false;
|
||||||
if (name !== 'spec') {
|
|
||||||
throw new Error('Unexpected query param ' + name);
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
reporter = new jasmineUnderTest.HtmlReporter(reporterConfig);
|
reporter = new jasmineUnderTest.HtmlReporter(reporterConfig);
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||||
@@ -1410,12 +1397,7 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
describe('when the specs are filtered', function() {
|
describe('when the specs are filtered', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
reporterConfig.queryString.getParam = function(name) {
|
reporterConfig.filterSpecs = true;
|
||||||
if (name !== 'spec') {
|
|
||||||
throw new Error('Unexpected query param ' + name);
|
|
||||||
}
|
|
||||||
return 'not the empty string';
|
|
||||||
};
|
|
||||||
reporter = new jasmineUnderTest.HtmlReporter(reporterConfig);
|
reporter = new jasmineUnderTest.HtmlReporter(reporterConfig);
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||||
@@ -1559,7 +1541,6 @@ describe('HtmlReporter', function() {
|
|||||||
|
|
||||||
const failingSpecResult = {
|
const failingSpecResult = {
|
||||||
id: 124,
|
id: 124,
|
||||||
parentSuiteId: 2,
|
|
||||||
status: 'failed',
|
status: 'failed',
|
||||||
description: 'a failing spec',
|
description: 'a failing spec',
|
||||||
fullName: 'a suite inner suite a failing spec',
|
fullName: 'a suite inner suite a failing spec',
|
||||||
@@ -1683,18 +1664,16 @@ describe('HtmlReporter', function() {
|
|||||||
expect(links.length).toEqual(3);
|
expect(links.length).toEqual(3);
|
||||||
expect(links[0].textContent).toEqual('A suite');
|
expect(links[0].textContent).toEqual('A suite');
|
||||||
|
|
||||||
expect(links[0].getAttribute('href')).toEqual(
|
expect(links[0].getAttribute('href')).toMatch(/\?foo=bar&spec=A suite/);
|
||||||
'/?foo=bar&spec=["A suite"]'
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(links[1].textContent).toEqual('inner suite');
|
expect(links[1].textContent).toEqual('inner suite');
|
||||||
expect(links[1].getAttribute('href')).toEqual(
|
expect(links[1].getAttribute('href')).toMatch(
|
||||||
'/?foo=bar&spec=["A suite","inner suite"]'
|
/\?foo=bar&spec=A suite inner suite/
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(links[2].textContent).toEqual('a failing spec');
|
expect(links[2].textContent).toEqual('a failing spec');
|
||||||
expect(links[2].getAttribute('href')).toEqual(
|
expect(links[2].getAttribute('href')).toMatch(
|
||||||
'/?foo=bar&spec=["A suite","inner suite","a failing spec"]'
|
/\?foo=bar&spec=a suite inner suite a failing spec/
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
describe('HtmlSpecFilter', function() {
|
describe('jasmineUnderTest.HtmlSpecFilter', function() {
|
||||||
it('should match when no string is provided', function() {
|
it('should match when no string is provided', function() {
|
||||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter();
|
const specFilter = new jasmineUnderTest.HtmlSpecFilter();
|
||||||
|
|
||||||
@@ -16,17 +16,4 @@ describe('HtmlSpecFilter', function() {
|
|||||||
expect(specFilter.matches('foo')).toBe(true);
|
expect(specFilter.matches('foo')).toBe(true);
|
||||||
expect(specFilter.matches('bar')).toBe(false);
|
expect(specFilter.matches('bar')).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('copes with HtmlExactSpecFilterV2 filter strings', function() {
|
|
||||||
const specFilter = new jasmineUnderTest.HtmlSpecFilter({
|
|
||||||
filterString: function() {
|
|
||||||
return '["foo","bar"]';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(specFilter.matches('foo bar')).toBe(true);
|
|
||||||
expect(specFilter.matches('baz foo bar qux')).toBe(true);
|
|
||||||
expect(specFilter.matches('foo')).toBe(false);
|
|
||||||
expect(specFilter.matches('bar')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
+16
-3
@@ -16,12 +16,20 @@
|
|||||||
(function() {
|
(function() {
|
||||||
const env = jasmine.getEnv();
|
const env = jasmine.getEnv();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ## Runner Parameters
|
||||||
|
*
|
||||||
|
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
||||||
|
*/
|
||||||
|
|
||||||
const queryString = new jasmine.QueryString({
|
const queryString = new jasmine.QueryString({
|
||||||
getWindowLocation: function() {
|
getWindowLocation: function() {
|
||||||
return window.location;
|
return window.location;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const filterSpecs = !!queryString.getParam('spec');
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
|
stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
|
||||||
stopSpecOnExpectationFailure: queryString.getParam(
|
stopSpecOnExpectationFailure: queryString.getParam(
|
||||||
@@ -63,7 +71,7 @@
|
|||||||
return document.createTextNode.apply(document, arguments);
|
return document.createTextNode.apply(document, arguments);
|
||||||
},
|
},
|
||||||
timer: new jasmine.Timer(),
|
timer: new jasmine.Timer(),
|
||||||
queryString
|
filterSpecs: filterSpecs
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,9 +83,14 @@
|
|||||||
/**
|
/**
|
||||||
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
||||||
*/
|
*/
|
||||||
const specFilter = new jasmine.HtmlExactSpecFilter({ queryString });
|
const specFilter = new jasmine.HtmlSpecFilter({
|
||||||
|
filterString: function() {
|
||||||
|
return queryString.getParam('spec');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
config.specFilter = function(spec) {
|
config.specFilter = function(spec) {
|
||||||
return specFilter.matches(spec);
|
return specFilter.matches(spec.getFullName());
|
||||||
};
|
};
|
||||||
|
|
||||||
env.configure(config);
|
env.configure(config);
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
jasmineRequire.HtmlExactSpecFilter = function() {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spec filter for use with {@link HtmlReporter}
|
|
||||||
*
|
|
||||||
* See lib/jasmine-core/boot1.js for usage.
|
|
||||||
* @since 5.11.0
|
|
||||||
*/
|
|
||||||
class HtmlExactSpecFilter {
|
|
||||||
#getFilterString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a filter instance.
|
|
||||||
* @param options Object with a queryString property, which should be an
|
|
||||||
* instance of {@link QueryString}.
|
|
||||||
*/
|
|
||||||
constructor(options) {
|
|
||||||
this.#getFilterString = function() {
|
|
||||||
return options.queryString.getParam('spec');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the specified spec should be executed.
|
|
||||||
* @param {Spec} spec
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
matches(spec) {
|
|
||||||
const filterString = this.#getFilterString();
|
|
||||||
|
|
||||||
if (!filterString) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filterPath = JSON.parse(this.#getFilterString());
|
|
||||||
const specPath = spec.getPath();
|
|
||||||
|
|
||||||
if (filterPath.length > specPath.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < filterPath.length; i++) {
|
|
||||||
if (specPath[i] !== filterPath[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return HtmlExactSpecFilter;
|
|
||||||
};
|
|
||||||
+17
-30
@@ -7,13 +7,11 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
this.specsExecuted = 0;
|
this.specsExecuted = 0;
|
||||||
this.failureCount = 0;
|
this.failureCount = 0;
|
||||||
this.pendingSpecCount = 0;
|
this.pendingSpecCount = 0;
|
||||||
this.suitesById = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultsStateBuilder.prototype.suiteStarted = function(result) {
|
ResultsStateBuilder.prototype.suiteStarted = function(result) {
|
||||||
this.currentParent.addChild(result, 'suite');
|
this.currentParent.addChild(result, 'suite');
|
||||||
this.currentParent = this.currentParent.last();
|
this.currentParent = this.currentParent.last();
|
||||||
this.suitesById[result.id] = this.currentParent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ResultsStateBuilder.prototype.suiteDone = function(result) {
|
ResultsStateBuilder.prototype.suiteDone = function(result) {
|
||||||
@@ -66,14 +64,10 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
const getContainer = options.getContainer;
|
const getContainer = options.getContainer;
|
||||||
const createElement = options.createElement;
|
const createElement = options.createElement;
|
||||||
const createTextNode = options.createTextNode;
|
const createTextNode = options.createTextNode;
|
||||||
// TODO: in the next major release, replace navigateWithNewParam and
|
|
||||||
// addToExistingQueryString with direct usage of options.queryString
|
|
||||||
const navigateWithNewParam = options.navigateWithNewParam || function() {};
|
const navigateWithNewParam = options.navigateWithNewParam || function() {};
|
||||||
const addToExistingQueryString =
|
const addToExistingQueryString =
|
||||||
options.addToExistingQueryString || defaultQueryString;
|
options.addToExistingQueryString || defaultQueryString;
|
||||||
const filterSpecs = options.queryString
|
const filterSpecs = options.filterSpecs;
|
||||||
? !!options.queryString.getParam('spec')
|
|
||||||
: options.filterSpecs; // For compatibility with pre-5.11 boot files
|
|
||||||
let htmlReporterMain;
|
let htmlReporterMain;
|
||||||
let symbols;
|
let symbols;
|
||||||
const deprecationWarnings = [];
|
const deprecationWarnings = [];
|
||||||
@@ -702,6 +696,21 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function suiteHref(suite) {
|
||||||
|
const els = [];
|
||||||
|
|
||||||
|
while (suite && suite.parent) {
|
||||||
|
els.unshift(suite.result.description);
|
||||||
|
suite = suite.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
|
||||||
|
return (
|
||||||
|
(window.location.pathname || '') +
|
||||||
|
addToExistingQueryString('spec', els.join(' '))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function addDeprecationWarnings(result, runnableType) {
|
function addDeprecationWarnings(result, runnableType) {
|
||||||
if (result && result.deprecationWarnings) {
|
if (result && result.deprecationWarnings) {
|
||||||
for (let i = 0; i < result.deprecationWarnings.length; i++) {
|
for (let i = 0; i < result.deprecationWarnings.length; i++) {
|
||||||
@@ -799,33 +808,11 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
return '' + count + ' ' + word;
|
return '' + count + ' ' + word;
|
||||||
}
|
}
|
||||||
|
|
||||||
function suitePath(suite) {
|
|
||||||
const els = [];
|
|
||||||
|
|
||||||
while (suite && suite.parent) {
|
|
||||||
els.unshift(suite.result.description);
|
|
||||||
suite = suite.parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return els;
|
|
||||||
}
|
|
||||||
|
|
||||||
function suiteHref(suite) {
|
|
||||||
return pathHref(suitePath(suite));
|
|
||||||
}
|
|
||||||
|
|
||||||
function specHref(result) {
|
function specHref(result) {
|
||||||
const suite = stateBuilder.suitesById[result.parentSuiteId];
|
|
||||||
const path = suitePath(suite);
|
|
||||||
path.push(result.description);
|
|
||||||
return pathHref(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pathHref(path) {
|
|
||||||
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
|
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
|
||||||
return (
|
return (
|
||||||
(window.location.pathname || '') +
|
(window.location.pathname || '') +
|
||||||
addToExistingQueryString('spec', JSON.stringify(path))
|
addToExistingQueryString('spec', result.fullName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,11 @@
|
|||||||
jasmineRequire.HtmlSpecFilter = function() {
|
jasmineRequire.HtmlSpecFilter = function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
|
||||||
* @name HtmlSpecFilter
|
|
||||||
* @classdesc Legacy HTML spec filter, for backward compatibility
|
|
||||||
* with boot files that predate {@link HtmlExactSpecFilter}.
|
|
||||||
* @param options Object with a filterString method
|
|
||||||
* @constructor
|
|
||||||
* @deprecated
|
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
|
||||||
// Legacy HTML spec filter, preserved for backward compatibility with
|
|
||||||
// boot files that predate HtmlExactSpecFilterV2
|
|
||||||
function HtmlSpecFilter(options) {
|
function HtmlSpecFilter(options) {
|
||||||
let filterString = (options && options.filterString()) || '';
|
const filterString =
|
||||||
|
options &&
|
||||||
if (filterString.startsWith('[')) {
|
options.filterString() &&
|
||||||
// Convert an HtmlExactSpecFilterV2 string into something we can use
|
options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||||
filterString = JSON.parse(filterString).join(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
filterString = filterString.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
||||||
|
|
||||||
const filterPattern = new RegExp(filterString);
|
const filterPattern = new RegExp(filterString);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,5 +6,4 @@ jasmineRequire.html = function(j$) {
|
|||||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||||
j$.QueryString = jasmineRequire.QueryString();
|
j$.QueryString = jasmineRequire.QueryString();
|
||||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||||
j$.HtmlExactSpecFilter = jasmineRequire.HtmlExactSpecFilter();
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user