Deprecate access to non-public Spec properties in spec filters

This commit is contained in:
Steve Gravrock
2025-09-14 11:34:06 -07:00
parent 6d77f3e7f0
commit 3cbf4dc27b
6 changed files with 125 additions and 10 deletions

View File

@@ -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 = {