Deprecated access to non-public members in specs and suites returned from it(), describe(), etc.

This commit is contained in:
Steve Gravrock
2021-07-29 21:28:47 -07:00
parent 2a2a671b65
commit 799d9897fd
6 changed files with 131 additions and 28 deletions

View File

@@ -1117,7 +1117,7 @@ getJasmineRequireObj().Env = function(j$) {
'Please either remove the describe or add children to it.'
);
}
return suite;
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
};
this.xdescribe = function(description, specDefinitions) {
@@ -1126,7 +1126,7 @@ getJasmineRequireObj().Env = function(j$) {
var suite = suiteFactory(description);
suite.pend();
addSpecsToSuite(suite, specDefinitions);
return suite;
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
};
var focusedRunnables = [];
@@ -1141,7 +1141,7 @@ getJasmineRequireObj().Env = function(j$) {
unfocusAncestor();
addSpecsToSuite(suite, specDefinitions);
return suite;
return j$.deprecatingSuiteProxy(suite, suite.parentSuite, this);
};
function addSpecsToSuite(suite, specDefinitions) {
@@ -1231,7 +1231,7 @@ getJasmineRequireObj().Env = function(j$) {
}
};
this.it = function(description, fn, timeout) {
this.it_ = function(description, fn, timeout) {
ensureIsNotNested('it');
// it() sometimes doesn't have a fn argument, so only check the type if
// it's given.
@@ -1243,9 +1243,15 @@ getJasmineRequireObj().Env = function(j$) {
spec.pend();
}
currentDeclarationSuite.addChild(spec);
return spec;
};
this.it = function(description, fn, timeout) {
var spec = this.it_(description, fn, timeout);
return j$.deprecatingSpecProxy(spec, this);
};
this.xit = function(description, fn, timeout) {
ensureIsNotNested('xit');
// xit(), like it(), doesn't always have a fn argument, so only check the
@@ -1253,9 +1259,9 @@ getJasmineRequireObj().Env = function(j$) {
if (arguments.length > 1 && typeof fn !== 'undefined') {
ensureIsFunctionOrAsync(fn, 'xit');
}
var spec = this.it.apply(this, arguments);
var spec = this.it_.apply(this, arguments);
spec.pend('Temporarily disabled with xit');
return spec;
return j$.deprecatingSpecProxy(spec, this);
};
this.fit = function(description, fn, timeout) {
@@ -1265,7 +1271,7 @@ getJasmineRequireObj().Env = function(j$) {
currentDeclarationSuite.addChild(spec);
focusedRunnables.push(spec.id);
unfocusAncestor();
return spec;
return j$.deprecatingSpecProxy(spec, this);
};
/**

View File

@@ -17,7 +17,7 @@ getJasmineRequireObj().deprecatingSpecProxy = function(j$) {
return (
'Access to private Spec members (in this case `' +
memberName +
'`) via Env#topSuite is not supported and will break in ' +
'`) is not supported and will break in ' +
'a future release. See <https://jasmine.github.io/api/edge/Spec.html> ' +
'for correct usage.'
);

View File

@@ -25,7 +25,7 @@ getJasmineRequireObj().deprecatingSuiteProxy = function(j$) {
return (
'Access to private Suite members (in this case `' +
memberName +
'`) via Env#topSuite is not supported and will break in ' +
'`) is not supported and will break in ' +
'a future release. See <https://jasmine.github.io/api/edge/Suite.html> ' +
'for correct usage.'
);