Show the name of the spec/suite that caused a deprecation
This commit is contained in:
@@ -132,7 +132,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
if (result.status === 'failed') {
|
if (result.status === 'failed') {
|
||||||
failures.push(failureDom(result));
|
failures.push(failureDom(result));
|
||||||
}
|
}
|
||||||
addDeprecationWarnings(result);
|
addDeprecationWarnings(result, 'suite');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.specStarted = function(result) {
|
this.specStarted = function(result) {
|
||||||
@@ -168,7 +168,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
failures.push(failureDom(result));
|
failures.push(failureDom(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
addDeprecationWarnings(result);
|
addDeprecationWarnings(result, 'spec');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.displaySpecInCorrectFormat = function(result) {
|
this.displaySpecInCorrectFormat = function(result) {
|
||||||
@@ -307,14 +307,27 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
addDeprecationWarnings(doneResult);
|
addDeprecationWarnings(doneResult);
|
||||||
|
|
||||||
var warningBarClassName = 'jasmine-bar jasmine-warning';
|
|
||||||
for (i = 0; i < deprecationWarnings.length; i++) {
|
for (i = 0; i < deprecationWarnings.length; i++) {
|
||||||
var warning = deprecationWarnings[i];
|
var context;
|
||||||
|
|
||||||
|
switch (deprecationWarnings[i].runnableType) {
|
||||||
|
case 'spec':
|
||||||
|
context = '(in spec: ' + deprecationWarnings[i].runnableName + ')';
|
||||||
|
break;
|
||||||
|
case 'suite':
|
||||||
|
context = '(in suite: ' + deprecationWarnings[i].runnableName + ')';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
context = '';
|
||||||
|
}
|
||||||
|
|
||||||
alert.appendChild(
|
alert.appendChild(
|
||||||
createDom(
|
createDom(
|
||||||
'span',
|
'span',
|
||||||
{ className: warningBarClassName },
|
{ className: 'jasmine-bar jasmine-warning' },
|
||||||
'DEPRECATION: ' + warning
|
'DEPRECATION: ' + deprecationWarnings[i].message,
|
||||||
|
createDom('br'),
|
||||||
|
context
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -625,12 +638,18 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
return addToExistingQueryString('spec', els.join(' '));
|
return addToExistingQueryString('spec', els.join(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDeprecationWarnings(result) {
|
function addDeprecationWarnings(result, runnableType) {
|
||||||
if (result && result.deprecationWarnings) {
|
if (result && result.deprecationWarnings) {
|
||||||
for (var i = 0; i < result.deprecationWarnings.length; i++) {
|
for (var i = 0; i < result.deprecationWarnings.length; i++) {
|
||||||
var warning = result.deprecationWarnings[i].message;
|
var warning = result.deprecationWarnings[i].message;
|
||||||
|
debugger;
|
||||||
if (!j$.util.arrayContains(warning)) {
|
if (!j$.util.arrayContains(warning)) {
|
||||||
deprecationWarnings.push(warning);
|
debugger;
|
||||||
|
deprecationWarnings.push({
|
||||||
|
message: warning,
|
||||||
|
runnableName: result.fullName,
|
||||||
|
runnableType: runnableType
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-11
@@ -1537,12 +1537,22 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
this.deprecated = function(deprecation) {
|
this.deprecated = function(deprecation) {
|
||||||
var runnable = currentRunnable() || topSuite;
|
var runnable = currentRunnable() || topSuite;
|
||||||
|
var context;
|
||||||
|
|
||||||
|
if (runnable === topSuite) {
|
||||||
|
context = '';
|
||||||
|
} else if (runnable === currentSuite()) {
|
||||||
|
context = ' (in suite: ' + runnable.getFullName() + ')';
|
||||||
|
} else {
|
||||||
|
context = ' (in spec: ' + runnable.getFullName() + ')';
|
||||||
|
}
|
||||||
|
|
||||||
runnable.addDeprecationWarning(deprecation);
|
runnable.addDeprecationWarning(deprecation);
|
||||||
if (
|
if (
|
||||||
typeof console !== 'undefined' &&
|
typeof console !== 'undefined' &&
|
||||||
typeof console.error === 'function'
|
typeof console.error === 'function'
|
||||||
) {
|
) {
|
||||||
console.error('DEPRECATION:', deprecation);
|
console.error('DEPRECATION: ' + deprecation + context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -7151,17 +7161,21 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
if (retval && j$.isFunction_(retval.then)) {
|
if (retval && j$.isFunction_(retval.then)) {
|
||||||
// Issue a warning that matches the user's code
|
// Issue a warning that matches the user's code
|
||||||
if (j$.isAsyncFunction_(fn)) {
|
if (j$.isAsyncFunction_(fn)) {
|
||||||
this.deprecated('An asynchronous before/it/after ' +
|
this.deprecated(
|
||||||
'function was defined with the async keyword but also took a ' +
|
'An asynchronous before/it/after ' +
|
||||||
'done callback. This is not supported and will stop working in' +
|
'function was defined with the async keyword but also took a ' +
|
||||||
' the future. Either remove the done callback (recommended) or ' +
|
'done callback. This is not supported and will stop working in' +
|
||||||
'remove the async keyword.');
|
' the future. Either remove the done callback (recommended) or ' +
|
||||||
|
'remove the async keyword.'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.deprecated('An asynchronous before/it/after ' +
|
this.deprecated(
|
||||||
'function took a done callback but also returned a promise. ' +
|
'An asynchronous before/it/after ' +
|
||||||
'This is not supported and will stop working in the future. ' +
|
'function took a done callback but also returned a promise. ' +
|
||||||
'Either remove the done callback (recommended) or change the ' +
|
'This is not supported and will stop working in the future. ' +
|
||||||
'function to not return a promise.');
|
'Either remove the done callback (recommended) or change the ' +
|
||||||
|
'function to not return a promise.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -528,11 +528,12 @@ describe('QueueRunner', function() {
|
|||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
expect(deprecated).toHaveBeenCalledWith('An asynchronous ' +
|
expect(deprecated).toHaveBeenCalledWith(
|
||||||
'before/it/after function took a done callback but also returned a '+
|
'An asynchronous ' +
|
||||||
'promise. This is not supported and will stop working in the future. ' +
|
'before/it/after function took a done callback but also returned a ' +
|
||||||
'Either remove the done callback (recommended) or change the function ' +
|
'promise. This is not supported and will stop working in the future. ' +
|
||||||
'to not return a promise.'
|
'Either remove the done callback (recommended) or change the function ' +
|
||||||
|
'to not return a promise.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -541,17 +542,18 @@ describe('QueueRunner', function() {
|
|||||||
eval('var fn = async function(done){};');
|
eval('var fn = async function(done){};');
|
||||||
var deprecated = jasmine.createSpy('deprecated'),
|
var deprecated = jasmine.createSpy('deprecated'),
|
||||||
queueRunner = new jasmineUnderTest.QueueRunner({
|
queueRunner = new jasmineUnderTest.QueueRunner({
|
||||||
queueableFns: [{fn: fn}],
|
queueableFns: [{ fn: fn }],
|
||||||
deprecated: deprecated
|
deprecated: deprecated
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
expect(deprecated).toHaveBeenCalledWith('An asynchronous ' +
|
expect(deprecated).toHaveBeenCalledWith(
|
||||||
'before/it/after function was defined with the async keyword but ' +
|
'An asynchronous ' +
|
||||||
'also took a done callback. This is not supported and will stop ' +
|
'before/it/after function was defined with the async keyword but ' +
|
||||||
'working in the future. Either remove the done callback ' +
|
'also took a done callback. This is not supported and will stop ' +
|
||||||
'(recommended) or remove the async keyword.'
|
'working in the future. Either remove the done callback ' +
|
||||||
|
'(recommended) or remove the async keyword.'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2294,7 +2294,7 @@ describe("Env integration", function() {
|
|||||||
it('should report deprecation warnings on the correct specs and suites', function(done) {
|
it('should report deprecation warnings on the correct specs and suites', function(done) {
|
||||||
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
// prevent deprecation from being displayed
|
// prevent deprecation from being displayed, as well as letting us observe calls
|
||||||
spyOn(console, "error");
|
spyOn(console, "error");
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
@@ -2316,6 +2316,7 @@ describe("Env integration", function() {
|
|||||||
expect(result.deprecationWarnings).toEqual([
|
expect(result.deprecationWarnings).toEqual([
|
||||||
jasmine.objectContaining({ message: 'top level deprecation' })
|
jasmine.objectContaining({ message: 'top level deprecation' })
|
||||||
]);
|
]);
|
||||||
|
expect(console.error).toHaveBeenCalledWith('DEPRECATION: top level deprecation');
|
||||||
|
|
||||||
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
fullName: 'suite',
|
fullName: 'suite',
|
||||||
@@ -2323,6 +2324,7 @@ describe("Env integration", function() {
|
|||||||
jasmine.objectContaining({ message: 'suite level deprecation' })
|
jasmine.objectContaining({ message: 'suite level deprecation' })
|
||||||
]
|
]
|
||||||
}));
|
}));
|
||||||
|
expect(console.error).toHaveBeenCalledWith('DEPRECATION: suite level deprecation (in suite: suite)');
|
||||||
|
|
||||||
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
fullName: 'suite spec',
|
fullName: 'suite spec',
|
||||||
@@ -2330,6 +2332,7 @@ describe("Env integration", function() {
|
|||||||
jasmine.objectContaining({ message: 'spec level deprecation' })
|
jasmine.objectContaining({ message: 'spec level deprecation' })
|
||||||
]
|
]
|
||||||
}));
|
}));
|
||||||
|
expect(console.error).toHaveBeenCalledWith('DEPRECATION: spec level deprecation (in spec: suite spec)');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -270,12 +270,14 @@ describe('HtmlReporter', function() {
|
|||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
reporter.specDone({
|
reporter.specDone({
|
||||||
status: 'passed',
|
status: 'passed',
|
||||||
|
fullName: 'a spec with a deprecation',
|
||||||
deprecationWarnings: [{ message: 'spec deprecation' }],
|
deprecationWarnings: [{ message: 'spec deprecation' }],
|
||||||
failedExpectations: [],
|
failedExpectations: [],
|
||||||
passedExpectations: []
|
passedExpectations: []
|
||||||
});
|
});
|
||||||
reporter.suiteDone({
|
reporter.suiteDone({
|
||||||
status: 'passed',
|
status: 'passed',
|
||||||
|
fullName: 'a suite with a deprecation',
|
||||||
deprecationWarnings: [{ message: 'suite deprecation' }],
|
deprecationWarnings: [{ message: 'suite deprecation' }],
|
||||||
failedExpectations: []
|
failedExpectations: []
|
||||||
});
|
});
|
||||||
@@ -287,12 +289,17 @@ describe('HtmlReporter', function() {
|
|||||||
var alertBars = container.querySelectorAll('.jasmine-alert .jasmine-bar');
|
var alertBars = container.querySelectorAll('.jasmine-alert .jasmine-bar');
|
||||||
|
|
||||||
expect(alertBars.length).toEqual(4);
|
expect(alertBars.length).toEqual(4);
|
||||||
expect(alertBars[1].innerHTML).toMatch(/spec deprecation/);
|
expect(alertBars[1].innerHTML).toMatch(
|
||||||
|
/spec deprecation.*\(in spec: a spec with a deprecation\)/
|
||||||
|
);
|
||||||
expect(alertBars[1].getAttribute('class')).toEqual(
|
expect(alertBars[1].getAttribute('class')).toEqual(
|
||||||
'jasmine-bar jasmine-warning'
|
'jasmine-bar jasmine-warning'
|
||||||
);
|
);
|
||||||
expect(alertBars[2].innerHTML).toMatch(/suite deprecation/);
|
expect(alertBars[2].innerHTML).toMatch(
|
||||||
|
/suite deprecation.*\(in suite: a suite with a deprecation\)/
|
||||||
|
);
|
||||||
expect(alertBars[3].innerHTML).toMatch(/global deprecation/);
|
expect(alertBars[3].innerHTML).toMatch(/global deprecation/);
|
||||||
|
expect(alertBars[3].innerHTML).not.toMatch(/in /);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+11
-1
@@ -581,12 +581,22 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
this.deprecated = function(deprecation) {
|
this.deprecated = function(deprecation) {
|
||||||
var runnable = currentRunnable() || topSuite;
|
var runnable = currentRunnable() || topSuite;
|
||||||
|
var context;
|
||||||
|
|
||||||
|
if (runnable === topSuite) {
|
||||||
|
context = '';
|
||||||
|
} else if (runnable === currentSuite()) {
|
||||||
|
context = ' (in suite: ' + runnable.getFullName() + ')';
|
||||||
|
} else {
|
||||||
|
context = ' (in spec: ' + runnable.getFullName() + ')';
|
||||||
|
}
|
||||||
|
|
||||||
runnable.addDeprecationWarning(deprecation);
|
runnable.addDeprecationWarning(deprecation);
|
||||||
if (
|
if (
|
||||||
typeof console !== 'undefined' &&
|
typeof console !== 'undefined' &&
|
||||||
typeof console.error === 'function'
|
typeof console.error === 'function'
|
||||||
) {
|
) {
|
||||||
console.error('DEPRECATION:', deprecation);
|
console.error('DEPRECATION: ' + deprecation + context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+14
-10
@@ -218,17 +218,21 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
if (retval && j$.isFunction_(retval.then)) {
|
if (retval && j$.isFunction_(retval.then)) {
|
||||||
// Issue a warning that matches the user's code
|
// Issue a warning that matches the user's code
|
||||||
if (j$.isAsyncFunction_(fn)) {
|
if (j$.isAsyncFunction_(fn)) {
|
||||||
this.deprecated('An asynchronous before/it/after ' +
|
this.deprecated(
|
||||||
'function was defined with the async keyword but also took a ' +
|
'An asynchronous before/it/after ' +
|
||||||
'done callback. This is not supported and will stop working in' +
|
'function was defined with the async keyword but also took a ' +
|
||||||
' the future. Either remove the done callback (recommended) or ' +
|
'done callback. This is not supported and will stop working in' +
|
||||||
'remove the async keyword.');
|
' the future. Either remove the done callback (recommended) or ' +
|
||||||
|
'remove the async keyword.'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.deprecated('An asynchronous before/it/after ' +
|
this.deprecated(
|
||||||
'function took a done callback but also returned a promise. ' +
|
'An asynchronous before/it/after ' +
|
||||||
'This is not supported and will stop working in the future. ' +
|
'function took a done callback but also returned a promise. ' +
|
||||||
'Either remove the done callback (recommended) or change the ' +
|
'This is not supported and will stop working in the future. ' +
|
||||||
'function to not return a promise.');
|
'Either remove the done callback (recommended) or change the ' +
|
||||||
|
'function to not return a promise.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
if (result.status === 'failed') {
|
if (result.status === 'failed') {
|
||||||
failures.push(failureDom(result));
|
failures.push(failureDom(result));
|
||||||
}
|
}
|
||||||
addDeprecationWarnings(result);
|
addDeprecationWarnings(result, 'suite');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.specStarted = function(result) {
|
this.specStarted = function(result) {
|
||||||
@@ -137,7 +137,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
failures.push(failureDom(result));
|
failures.push(failureDom(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
addDeprecationWarnings(result);
|
addDeprecationWarnings(result, 'spec');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.displaySpecInCorrectFormat = function(result) {
|
this.displaySpecInCorrectFormat = function(result) {
|
||||||
@@ -276,14 +276,27 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
addDeprecationWarnings(doneResult);
|
addDeprecationWarnings(doneResult);
|
||||||
|
|
||||||
var warningBarClassName = 'jasmine-bar jasmine-warning';
|
|
||||||
for (i = 0; i < deprecationWarnings.length; i++) {
|
for (i = 0; i < deprecationWarnings.length; i++) {
|
||||||
var warning = deprecationWarnings[i];
|
var context;
|
||||||
|
|
||||||
|
switch (deprecationWarnings[i].runnableType) {
|
||||||
|
case 'spec':
|
||||||
|
context = '(in spec: ' + deprecationWarnings[i].runnableName + ')';
|
||||||
|
break;
|
||||||
|
case 'suite':
|
||||||
|
context = '(in suite: ' + deprecationWarnings[i].runnableName + ')';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
context = '';
|
||||||
|
}
|
||||||
|
|
||||||
alert.appendChild(
|
alert.appendChild(
|
||||||
createDom(
|
createDom(
|
||||||
'span',
|
'span',
|
||||||
{ className: warningBarClassName },
|
{ className: 'jasmine-bar jasmine-warning' },
|
||||||
'DEPRECATION: ' + warning
|
'DEPRECATION: ' + deprecationWarnings[i].message,
|
||||||
|
createDom('br'),
|
||||||
|
context
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -594,12 +607,18 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
return addToExistingQueryString('spec', els.join(' '));
|
return addToExistingQueryString('spec', els.join(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDeprecationWarnings(result) {
|
function addDeprecationWarnings(result, runnableType) {
|
||||||
if (result && result.deprecationWarnings) {
|
if (result && result.deprecationWarnings) {
|
||||||
for (var i = 0; i < result.deprecationWarnings.length; i++) {
|
for (var i = 0; i < result.deprecationWarnings.length; i++) {
|
||||||
var warning = result.deprecationWarnings[i].message;
|
var warning = result.deprecationWarnings[i].message;
|
||||||
|
debugger;
|
||||||
if (!j$.util.arrayContains(warning)) {
|
if (!j$.util.arrayContains(warning)) {
|
||||||
deprecationWarnings.push(warning);
|
debugger;
|
||||||
|
deprecationWarnings.push({
|
||||||
|
message: warning,
|
||||||
|
runnableName: result.fullName,
|
||||||
|
runnableType: runnableType
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user