Merge branch '3.99' into 4.0

This commit is contained in:
Steve Gravrock
2021-05-29 18:42:31 -07:00
20 changed files with 1695 additions and 240 deletions

329
spec/core/DeprecatorSpec.js Normal file
View File

@@ -0,0 +1,329 @@
/* eslint no-console: 0 */
describe('Deprecator', function() {
describe('#deprecate', function() {
beforeEach(function() {
spyOn(console, 'error');
});
it('logs the mesage without context when the runnable is the top suite', function() {
var runnable = { addDeprecationWarning: function() {} };
var deprecator = new jasmineUnderTest.Deprecator(runnable);
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message', {
omitStackTrace: true
});
expect(console.error).toHaveBeenCalledWith('DEPRECATION: the message');
});
it('logs the message in a descendant suite', function() {
var runnable = {
addDeprecationWarning: function() {},
getFullName: function() {
return 'the suite';
},
children: []
};
var deprecator = new jasmineUnderTest.Deprecator({});
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message', {
omitStackTrace: true
});
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: the message (in suite: the suite)'
);
});
it('logs and reports the message in a spec', function() {
var runnable = {
addDeprecationWarning: function() {},
getFullName: function() {
return 'the spec';
}
};
var deprecator = new jasmineUnderTest.Deprecator({});
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message', {
omitStackTrace: true
});
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: the message (in spec: the spec)'
);
});
it('logs and reports the message without runnable info when ignoreRunnable is true', function() {
var topSuite = jasmine.createSpyObj('topSuite', [
'addDeprecationWarning',
'getFullName'
]);
var deprecator = new jasmineUnderTest.Deprecator(topSuite);
var runnable = jasmine.createSpyObj('spec', [
'addDeprecationWarning',
'getFullName'
]);
runnable.getFullName.and.returnValue('a spec');
deprecator.addDeprecationWarning(runnable, 'the message', {
ignoreRunnable: true
});
expect(topSuite.addDeprecationWarning).toHaveBeenCalledWith(
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
);
expect(runnable.addDeprecationWarning).not.toHaveBeenCalled();
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/the message/)
);
expect(console.error).not.toHaveBeenCalledWith(
jasmine.stringMatching(/a spec/)
);
});
describe('with no options', function() {
it('includes the stack trace', function() {
testStackTrace(undefined);
});
});
it('omits the stack trace when omitStackTrace is true', function() {
testNoStackTrace({ omitStackTrace: true });
});
it('includes the stack trace when omitStackTrace is false', function() {
testStackTrace({ omitStackTrace: false });
});
it('includes the stack trace when omitStackTrace is undefined', function() {
testStackTrace({ includeStackTrace: undefined });
});
it('emits the deprecation only once when verboseDeprecations is not set', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable1 = jasmine.createSpyObj('runnable1', [
'addDeprecationWarning',
'getFullName'
]);
var runnable2 = jasmine.createSpyObj('runnable2', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable2, 'the message');
expect(runnable1.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(runnable2.addDeprecationWarning).not.toHaveBeenCalled();
});
it('emits the deprecation only once when verboseDeprecations is false', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable1 = jasmine.createSpyObj('runnable1', [
'addDeprecationWarning',
'getFullName'
]);
var runnable2 = jasmine.createSpyObj('runnable2', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.verboseDeprecations(false);
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable2, 'the message');
expect(runnable1.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(runnable2.addDeprecationWarning).not.toHaveBeenCalled();
});
it('emits the deprecation for each call when verboseDeprecations is true', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable1 = jasmine.createSpyObj('runnable1', [
'addDeprecationWarning',
'getFullName'
]);
var runnable2 = jasmine.createSpyObj('runnable2', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable1, 'the message');
deprecator.addDeprecationWarning(runnable2, 'the message');
expect(runnable1.addDeprecationWarning).toHaveBeenCalledTimes(2);
expect(runnable2.addDeprecationWarning).toHaveBeenCalled();
});
it('includes a note about verboseDeprecations', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable, 'the message');
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).toContain(verboseDeprecationsNote());
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
verboseDeprecationsNote()
);
});
it('omits the note about verboseDeprecations when verboseDeprecations is true', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.verboseDeprecations(true);
deprecator.addDeprecationWarning(runnable, 'the message');
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).not.toContain(verboseDeprecationsNote());
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).not.toContain(
verboseDeprecationsNote()
);
});
describe('When the deprecation is an Error', function() {
// This form is used by external systems like atom-jasmine3-test-runner
// to report their own deprecations through Jasmine. See
// <https://github.com/jasmine/jasmine/pull/1498>.
it('passes the error through unchanged', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter();
var deprecation, originalStack;
try {
throw new Error('the deprecation');
} catch (err) {
deprecation = err;
originalStack = err.stack;
}
deprecator.addDeprecationWarning(runnable, deprecation);
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).toEqual('the deprecation');
expect(runnable.addDeprecationWarning.calls.argsFor(0)[0].stack).toBe(
originalStack
);
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0].message).toEqual(
'the deprecation'
);
expect(console.error.calls.argsFor(0)[0].stack).toEqual(originalStack);
});
it('reports the deprecation every time, regardless of config.verboseDeprecations', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
var deprecation;
try {
throw new Error('the deprecation');
} catch (err) {
deprecation = err;
}
deprecator.addDeprecationWarning(runnable, deprecation);
deprecator.addDeprecationWarning(runnable, deprecation);
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(2);
expect(console.error).toHaveBeenCalledTimes(2);
});
it('omits the note about verboseDeprecations', function() {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
var deprecation;
try {
throw new Error('the deprecation');
} catch (err) {
deprecation = err;
}
deprecator.addDeprecationWarning(runnable, deprecation);
expect(runnable.addDeprecationWarning).toHaveBeenCalledTimes(1);
expect(
runnable.addDeprecationWarning.calls.argsFor(0)[0].message
).not.toContain(verboseDeprecationsNote());
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).not.toContain(
verboseDeprecationsNote()
);
});
});
function verboseDeprecationsNote() {
return (
'Note: This message will be shown only once. Set ' +
'config.verboseDeprecations to true to see every occurrence.'
);
}
function testStackTrace(options) {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable, 'the message', options);
expect(runnable.addDeprecationWarning).toHaveBeenCalledWith({
message: jasmine.stringMatching(/^the message/),
omitStackTrace: false
});
expect(console.error).toHaveBeenCalledTimes(1);
expect(console.error.calls.argsFor(0)[0]).toContain('the message');
expect(console.error.calls.argsFor(0)[0]).toContain('DeprecatorSpec.js');
}
function testNoStackTrace(options) {
var deprecator = new jasmineUnderTest.Deprecator({});
var runnable = jasmine.createSpyObj('runnable', [
'addDeprecationWarning',
'getFullName'
]);
deprecator.addDeprecationWarning(runnable, 'the message', options);
expect(runnable.addDeprecationWarning).toHaveBeenCalledWith({
message: jasmine.stringMatching(/^the message/),
omitStackTrace: true
});
}
});
});

View File

@@ -26,9 +26,141 @@ describe('Env', function() {
});
describe('#topSuite', function() {
it('returns the Jasmine top suite for users to traverse the spec tree', function() {
var suite = env.topSuite();
it('returns an object that describes the tree of suites and specs', function() {
var suite;
spyOn(env, 'deprecated');
env.it('a top level spec');
env.describe('a suite', function() {
env.it('a spec');
env.describe('a nested suite', function() {
env.it('a nested spec');
});
});
suite = env.topSuite();
expect(suite.description).toEqual('Jasmine__TopLevel__Suite');
expect(suite.getFullName()).toEqual('');
expect(suite.children.length).toEqual(2);
expect(suite.children[0].description).toEqual('a top level spec');
expect(suite.children[0].getFullName()).toEqual('a top level spec');
expect(suite.children[0].children).toBeFalsy();
expect(suite.children[1].description).toEqual('a suite');
expect(suite.children[1].getFullName()).toEqual('a suite');
expect(suite.children[1].parentSuite).toBe(suite);
expect(suite.children[1].children.length).toEqual(2);
expect(suite.children[1].children[0].description).toEqual('a spec');
expect(suite.children[1].children[0].getFullName()).toEqual(
'a suite a spec'
);
expect(suite.children[1].children[0].children).toBeFalsy();
expect(suite.children[1].children[1].description).toEqual(
'a nested suite'
);
expect(suite.children[1].children[1].getFullName()).toEqual(
'a suite a nested suite'
);
expect(suite.children[1].children[1].parentSuite).toBe(suite.children[1]);
expect(suite.children[1].children[1].children.length).toEqual(1);
expect(suite.children[1].children[1].children[0].description).toEqual(
'a nested spec'
);
expect(suite.children[1].children[1].children[0].getFullName()).toEqual(
'a suite a nested suite a nested spec'
);
expect(suite.children[1].children[1].children[0].children).toBeFalsy();
});
it('does not deprecate access to public Suite and Spec members', function() {
jasmine.getEnv().requireProxy();
var suite;
spyOn(env, 'deprecated');
env.it('a top level spec');
env.describe('a suite', function() {
env.it('a spec');
});
suite = env.topSuite();
suite.description;
suite.getFullName();
suite.children;
suite.parentSuite;
suite.children[0].description;
suite.children[0].getFullName();
suite.children[0].children;
suite.children[1].description;
suite.children[1].getFullName();
suite.children[1].parentSuite;
suite.children[1].children;
expect(env.deprecated).not.toHaveBeenCalled();
});
it('deprecates access to internal Suite and Spec members', function() {
jasmine.getEnv().requireProxy();
var topSuite, expectationFactory, spec;
env.it('a top level spec');
spyOn(env, 'deprecated');
topSuite = env.topSuite();
topSuite.expectationFactory;
expect(env.deprecated).toHaveBeenCalledWith(
'Access to private Suite ' +
'members (in this case `expectationFactory`) via Env#topSuite is ' +
'not supported and will break in a future release. See ' +
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
);
env.deprecated.calls.reset();
topSuite.expectationFactory = expectationFactory;
expect(env.deprecated).toHaveBeenCalledWith(
'Access to private Suite ' +
'members (in this case `expectationFactory`) via Env#topSuite is ' +
'not supported and will break in a future release. See ' +
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
);
topSuite.status();
expect(env.deprecated).toHaveBeenCalledWith(
'Access to private Suite ' +
'members (in this case `status`) via Env#topSuite is ' +
'not supported and will break in a future release. See ' +
'<https://jasmine.github.io/api/edge/Suite.html> for correct usage.'
);
spec = topSuite.children[0];
spec.pend();
expect(env.deprecated).toHaveBeenCalledWith(
'Access to private Spec ' +
'members (in this case `pend`) via Env#topSuite ' +
'is not supported and will break in a future release. See ' +
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
);
expectationFactory = spec.expectationFactory;
expect(env.deprecated).toHaveBeenCalledWith(
'Access to private Spec ' +
'members (in this case `expectationFactory`) via Env#topSuite ' +
'is not supported and will break in a future release. See ' +
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
);
env.deprecated.calls.reset();
spec.expectationFactory = expectationFactory;
expect(env.deprecated).toHaveBeenCalledWith(
'Access to private Spec ' +
'members (in this case `expectationFactory`) via Env#topSuite ' +
'is not supported and will break in a future release. See ' +
'<https://jasmine.github.io/api/edge/Spec.html> for correct usage.'
);
});
});
@@ -289,60 +421,6 @@ describe('Env', function() {
});
});
describe('#deprecatedOnceWithStack', function() {
it('includes a stack trace', function() {
spyOn(env, 'deprecated');
env.deprecatedOnceWithStack('msg');
expect(env.deprecated).toHaveBeenCalled();
var msg = env.deprecated.calls.argsFor(0)[0];
expect(msg).toContain('msg');
expect(msg).toContain('EnvSpec.js');
expect(msg).not.toContain('Error');
});
describe('When verboseDeprecations is true', function() {
it('calls #deprecated every time', function() {
env.configure({ verboseDeprecations: true });
spyOn(env, 'deprecated');
env.deprecatedOnceWithStack('msg');
env.deprecatedOnceWithStack('msg');
expect(env.deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(/msg/)
);
expect(env.deprecated).toHaveBeenCalledTimes(2);
expect(env.deprecated).not.toHaveBeenCalledWith(
jasmine.stringMatching(/only once/)
);
});
});
describe('When verboseDeprecations is false', function() {
it('calls #deprecated once per unique message', function() {
env.configure({ verboseDeprecations: false });
spyOn(env, 'deprecated');
env.deprecatedOnceWithStack('foo');
env.deprecatedOnceWithStack('bar');
env.deprecatedOnceWithStack('foo');
expect(env.deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
/foo\nNote: This message will be shown only once. Set config.verboseDeprecations to true to see every occurrence/m
)
);
expect(env.deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
/bar\nNote: This message will be shown only once. Set config.verboseDeprecations to true to see every occurrence/m
)
);
expect(env.deprecated).toHaveBeenCalledTimes(2);
});
});
});
describe('when not constructed with suppressLoadErrors: true', function() {
it('installs a global error handler on construction', function() {
var globalErrors = jasmine.createSpyObj('globalErrors', [

View File

@@ -0,0 +1,322 @@
/* eslint no-console: 0 */
describe('Deprecation (integration)', function() {
var env;
beforeEach(function() {
env = new jasmineUnderTest.Env();
});
afterEach(function() {
env.cleanup_();
});
it('reports a deprecation on the top suite', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.beforeAll(function() {
env.deprecated('the message');
});
env.it('a spec', function() {});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/^DEPRECATION: the message/)
);
done();
});
});
it('reports a deprecation on a descendent suite', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['suiteDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.beforeAll(function() {
env.deprecated('the message');
});
env.it('a spec', function() {});
});
env.execute(null, function() {
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: the message \(in suite: a suite\)/
)
);
done();
});
});
it('reports a deprecation on a spec', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.it('a spec', function() {
env.deprecated('the message');
});
});
env.execute(null, function() {
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: the message \(in spec: a suite a spec\)/
)
);
done();
});
});
it('omits the suite or spec context when ignoreRunnable is true', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.it('a spec', function() {
env.deprecated('the message', { ignoreRunnable: true });
});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/the message/)
);
expect(console.error).not.toHaveBeenCalledWith(
jasmine.stringMatching(/a spec/)
);
done();
});
});
it('includes the stack trace', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.it('a spec', function() {
env.deprecated('the message');
});
});
env.execute(null, function() {
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
stack: jasmine.stringMatching(/DeprecationSpec.js/)
})
]
})
);
expect(console.error).toHaveBeenCalled();
expect(console.error.calls.argsFor(0)[0].replace(/\n/g, 'NL')).toMatch(
/^DEPRECATION: the message \(in spec: a suite a spec\)NL.*DeprecationSpec.js/
);
done();
});
});
it('excludes the stack trace when omitStackTrace is true', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.it('a spec', function() {
env.deprecated('the message', { omitStackTrace: true });
});
});
env.execute(null, function() {
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
stack: jasmine.falsy()
})
]
})
);
expect(console.error).toHaveBeenCalled();
expect(console.error).not.toHaveBeenCalledWith(
jasmine.stringMatching(/DeprecationSpec.js/)
);
done();
});
});
it('emits a given deprecation only once', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone', 'suiteDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.describe('a suite', function() {
env.beforeAll(function() {
env.deprecated('the message');
env.deprecated('the message');
});
env.it('a spec', function() {
env.deprecated('the message');
env.deprecated('a different message');
});
});
env.execute(null, function() {
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
// only one
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
// only the other one
jasmine.objectContaining({
message: jasmine.stringMatching(/^a different message/)
})
]
})
);
expect(console.error).toHaveBeenCalledTimes(2);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: the message \(in suite: a suite\)/
)
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(
/^DEPRECATION: a different message \(in spec: a suite a spec\)/
)
);
done();
});
});
it('emits a given deprecation each time when config.verboseDeprecations is true', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['specDone', 'suiteDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.configure({ verboseDeprecations: true });
env.describe('a suite', function() {
env.beforeAll(function() {
env.deprecated('the message');
env.deprecated('the message');
});
env.it('a spec', function() {
env.deprecated('the message');
});
});
env.execute(null, function() {
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
}),
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledTimes(3);
expect(console.error.calls.argsFor(0)[0]).toMatch(
/^DEPRECATION: the message \(in suite: a suite\)/
);
expect(console.error.calls.argsFor(1)[0]).toMatch(
/^DEPRECATION: the message \(in suite: a suite\)/
);
expect(console.error.calls.argsFor(2)[0]).toMatch(
/^DEPRECATION: the message \(in spec: a suite a spec\)/
);
expect(console.error.calls.argsFor(2)[0]).toMatch(
/^DEPRECATION: the message \(in spec: a suite a spec\)/
);
done();
});
});
it('handles deprecations that occur before execute() is called', function(done) {
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone']);
env.addReporter(reporter);
spyOn(console, 'error');
env.deprecated('the message');
env.it('a spec', function() {});
env.execute(null, function() {
expect(reporter.jasmineDone).toHaveBeenCalledWith(
jasmine.objectContaining({
deprecationWarnings: [
jasmine.objectContaining({
message: jasmine.stringMatching(/^the message/)
})
]
})
);
expect(console.error).toHaveBeenCalledWith(
jasmine.stringMatching(/^DEPRECATION: the message/)
);
done();
});
});
});

View File

@@ -2627,70 +2627,6 @@ 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, as well as letting us observe calls
spyOn(console, 'error');
env.addReporter(reporter);
env.deprecated('top level deprecation');
env.describe('suite', function() {
env.beforeAll(function() {
env.deprecated('suite level deprecation');
});
env.it('spec', function() {
env.deprecated('spec level deprecation');
});
});
env.execute(null, function() {
var result = reporter.jasmineDone.calls.argsFor(0)[0];
expect(result.deprecationWarnings).toEqual([
jasmine.objectContaining({ message: 'top level deprecation' })
]);
/* eslint-disable-next-line no-console */
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: top level deprecation'
);
expect(reporter.suiteDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'suite',
deprecationWarnings: [
jasmine.objectContaining({ message: 'suite level deprecation' })
]
})
);
/* eslint-disable-next-line no-console */
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: suite level deprecation (in suite: suite)'
);
expect(reporter.specDone).toHaveBeenCalledWith(
jasmine.objectContaining({
fullName: 'suite spec',
deprecationWarnings: [
jasmine.objectContaining({ message: 'spec level deprecation' })
]
})
);
/* eslint-disable-next-line no-console */
expect(console.error).toHaveBeenCalledWith(
'DEPRECATION: spec level deprecation (in spec: suite spec)'
);
done();
});
});
it('should report deprecation stack with an error object', function(done) {
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
reporter = jasmine.createSpyObj('reporter', [