Show the name of the spec/suite that caused a deprecation

This commit is contained in:
Steve Gravrock
2020-09-13 12:39:42 -07:00
parent 51ad18cb28
commit e7daa429a1
8 changed files with 130 additions and 52 deletions

View File

@@ -528,11 +528,12 @@ describe('QueueRunner', function() {
queueRunner.execute();
expect(deprecated).toHaveBeenCalledWith('An asynchronous ' +
'before/it/after function took a done callback but also returned a '+
'promise. This is not supported and will stop working in the future. ' +
'Either remove the done callback (recommended) or change the function ' +
'to not return a promise.'
expect(deprecated).toHaveBeenCalledWith(
'An asynchronous ' +
'before/it/after function took a done callback but also returned a ' +
'promise. This is not supported and will stop working in the future. ' +
'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){};');
var deprecated = jasmine.createSpy('deprecated'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [{fn: fn}],
queueableFns: [{ fn: fn }],
deprecated: deprecated
});
queueRunner.execute();
expect(deprecated).toHaveBeenCalledWith('An asynchronous ' +
'before/it/after function was defined with the async keyword but ' +
'also took a done callback. This is not supported and will stop ' +
'working in the future. Either remove the done callback ' +
'(recommended) or remove the async keyword.'
expect(deprecated).toHaveBeenCalledWith(
'An asynchronous ' +
'before/it/after function was defined with the async keyword but ' +
'also took a done callback. This is not supported and will stop ' +
'working in the future. Either remove the done callback ' +
'(recommended) or remove the async keyword.'
);
});
});

View File

@@ -2294,7 +2294,7 @@ describe("Env integration", function() {
it('should report deprecation warnings on the correct specs and suites', function(done) {
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");
env.addReporter(reporter);
@@ -2316,6 +2316,7 @@ describe("Env integration", function() {
expect(result.deprecationWarnings).toEqual([
jasmine.objectContaining({ message: 'top level deprecation' })
]);
expect(console.error).toHaveBeenCalledWith('DEPRECATION: top level deprecation');
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
fullName: 'suite',
@@ -2323,6 +2324,7 @@ describe("Env integration", function() {
jasmine.objectContaining({ message: 'suite level deprecation' })
]
}));
expect(console.error).toHaveBeenCalledWith('DEPRECATION: suite level deprecation (in suite: suite)');
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
fullName: 'suite spec',
@@ -2330,6 +2332,7 @@ describe("Env integration", function() {
jasmine.objectContaining({ message: 'spec level deprecation' })
]
}));
expect(console.error).toHaveBeenCalledWith('DEPRECATION: spec level deprecation (in spec: suite spec)');
done();
});

View File

@@ -270,12 +270,14 @@ describe('HtmlReporter', function() {
reporter.jasmineStarted({});
reporter.specDone({
status: 'passed',
fullName: 'a spec with a deprecation',
deprecationWarnings: [{ message: 'spec deprecation' }],
failedExpectations: [],
passedExpectations: []
});
reporter.suiteDone({
status: 'passed',
fullName: 'a suite with a deprecation',
deprecationWarnings: [{ message: 'suite deprecation' }],
failedExpectations: []
});
@@ -287,12 +289,17 @@ describe('HtmlReporter', function() {
var alertBars = container.querySelectorAll('.jasmine-alert .jasmine-bar');
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(
'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).not.toMatch(/in /);
});
});