Deprecate access to non-public Spec properties in spec filters
This commit is contained in:
@@ -913,6 +913,7 @@ describe('Env integration', function() {
|
||||
});
|
||||
|
||||
env.configure({
|
||||
random: false,
|
||||
specFilter: function(spec) {
|
||||
return /^first suite/.test(spec.getFullName());
|
||||
}
|
||||
@@ -920,13 +921,44 @@ describe('Env integration', function() {
|
||||
|
||||
await env.execute();
|
||||
|
||||
expect(calls.length).toEqual(2);
|
||||
expect(calls).toEqual(
|
||||
jasmine.arrayContaining(['first spec', 'second spec'])
|
||||
);
|
||||
expect(calls).toEqual(['first spec', 'second spec']);
|
||||
expect(suiteCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('reports a deprecation warning when a spec filter accesses private properties', async function() {
|
||||
env.it('a spec', function() {});
|
||||
|
||||
const reporter = jasmine.createSpyObj('reporter', ['jasmineDone']);
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.configure({
|
||||
random: false,
|
||||
specFilter: function(spec) {
|
||||
spec.result; // deprecated
|
||||
spec.id; // not deprecated
|
||||
spec.description; // not deprecated
|
||||
spec.getPath(); // not deprecated
|
||||
spec.getFullName(); // not deprecated
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
spyOn(console, 'error');
|
||||
await env.execute();
|
||||
|
||||
expect(reporter.jasmineDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
deprecationWarnings: [
|
||||
jasmine.objectContaining({
|
||||
message: jasmine.stringContaining(
|
||||
'Access to private Spec members (in this case `result`)'
|
||||
)
|
||||
})
|
||||
]
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('Functions can be spied on and have their calls tracked', async function() {
|
||||
let originalFunctionWasCalled = false;
|
||||
const subject = {
|
||||
|
||||
Reference in New Issue
Block a user