Merge branch '3.99' into 4.0

This commit is contained in:
Steve Gravrock
2021-07-31 09:15:12 -07:00
9 changed files with 302 additions and 33 deletions

View File

@@ -27,8 +27,8 @@
var filterSpecs = !!queryString.getParam("spec");
var config = {
failFast: queryString.getParam("failFast"),
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
stopOnSpecFailure: queryString.getParam("failFast"),
stopSpecOnExpectationFailure: queryString.getParam("oneFailurePerSpec"),
hideDisabled: queryString.getParam("hideDisabled")
};

View File

@@ -49,8 +49,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var filterSpecs = !!queryString.getParam("spec");
var config = {
failFast: queryString.getParam("failFast"),
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
stopOnSpecFailure: queryString.getParam("failFast"),
stopSpecOnExpectationFailure: queryString.getParam("oneFailurePerSpec"),
hideDisabled: queryString.getParam("hideDisabled")
};

View File

@@ -569,17 +569,20 @@ jasmineRequire.HtmlReporter = function(j$) {
);
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
failFastCheckbox.checked = config.failFast;
failFastCheckbox.checked = config.stopOnSpecFailure;
failFastCheckbox.onclick = function() {
navigateWithNewParam('failFast', !config.failFast);
navigateWithNewParam('failFast', !config.stopOnSpecFailure);
};
var throwCheckbox = optionsMenuDom.querySelector(
'#jasmine-throw-failures'
);
throwCheckbox.checked = config.oneFailurePerSpec;
throwCheckbox.checked = config.stopSpecOnExpectationFailure;
throwCheckbox.onclick = function() {
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec);
navigateWithNewParam(
'oneFailurePerSpec',
!config.stopSpecOnExpectationFailure
);
};
var randomCheckbox = optionsMenuDom.querySelector(

View File

@@ -1042,8 +1042,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopOnSpecFailure` config property instead.
*/
failFast: false,
/**
* Whether to stop execution of the suite after the first spec failure
* @name Configuration#stopOnSpecFailure
* @since 3.9.0
* @type Boolean
* @default false
*/
stopOnSpecFailure: false,
/**
* Whether to fail the spec if it ran no expectations. By default
* a spec that ran no expectations is reported as passed. Setting this
@@ -1060,8 +1069,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
*/
oneFailurePerSpec: false,
/**
* Whether to cause specs to only have one expectation failure.
* @name Configuration#stopSpecOnExpectationFailure
* @since 3.3.0
* @type Boolean
* @default false
*/
stopSpecOnExpectationFailure: false,
/**
* A function that takes a spec and returns true if it should be executed
* or false if it should be skipped.
@@ -1161,9 +1179,7 @@ getJasmineRequireObj().Env = function(j$) {
this.configure = function(configuration) {
var booleanProps = [
'random',
'failFast',
'failSpecWithNoExpectations',
'oneFailurePerSpec',
'hideDisabled'
];
@@ -1173,6 +1189,70 @@ getJasmineRequireObj().Env = function(j$) {
}
});
if (typeof configuration.failFast !== 'undefined') {
// We can't unconditionally issue a warning here because then users who
// get the configuration from Jasmine, modify it, and pass it back would
// see the warning.
if (configuration.failFast !== config.failFast) {
this.deprecated(
'The `failFast` config property is deprecated and will be removed ' +
'in a future version of Jasmine. Please use `stopOnSpecFailure` ' +
'instead.',
{ ignoreRunnable: true }
);
}
if (typeof configuration.stopOnSpecFailure !== 'undefined') {
if (configuration.stopOnSpecFailure !== configuration.failFast) {
throw new Error(
'stopOnSpecFailure and failFast are aliases for ' +
"each other. Don't set failFast if you also set stopOnSpecFailure."
);
}
}
config.failFast = configuration.failFast;
config.stopOnSpecFailure = configuration.failFast;
} else if (typeof configuration.stopOnSpecFailure !== 'undefined') {
config.failFast = configuration.stopOnSpecFailure;
config.stopOnSpecFailure = configuration.stopOnSpecFailure;
}
if (typeof configuration.oneFailurePerSpec !== 'undefined') {
// We can't unconditionally issue a warning here because then users who
// get the configuration from Jasmine, modify it, and pass it back would
// see the warning.
if (configuration.oneFailurePerSpec !== config.oneFailurePerSpec) {
this.deprecated(
'The `oneFailurePerSpec` config property is deprecated and will be ' +
'removed in a future version of Jasmine. Please use ' +
'`stopSpecOnExpectationFailure` instead.',
{ ignoreRunnable: true }
);
}
if (typeof configuration.stopSpecOnExpectationFailure !== 'undefined') {
if (
configuration.stopSpecOnExpectationFailure !==
configuration.oneFailurePerSpec
) {
throw new Error(
'stopSpecOnExpectationFailure and oneFailurePerSpec are aliases for ' +
"each other. Don't set oneFailurePerSpec if you also set stopSpecOnExpectationFailure."
);
}
}
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
config.stopSpecOnExpectationFailure = configuration.oneFailurePerSpec;
} else if (
typeof configuration.stopSpecOnExpectationFailure !== 'undefined'
) {
config.oneFailurePerSpec = configuration.stopSpecOnExpectationFailure;
config.stopSpecOnExpectationFailure =
configuration.stopSpecOnExpectationFailure;
}
if (configuration.specFilter) {
config.specFilter = configuration.specFilter;
}
@@ -1484,9 +1564,9 @@ getJasmineRequireObj().Env = function(j$) {
var queueRunnerFactory = function(options, args) {
var failFast = false;
if (options.isLeaf) {
failFast = config.oneFailurePerSpec;
failFast = config.stopSpecOnExpectationFailure;
} else if (!options.isReporter) {
failFast = config.failFast;
failFast = config.stopOnSpecFailure;
}
options.clearStack = options.clearStack || clearStack;
options.timeout = {

View File

@@ -88,7 +88,7 @@ describe('Env', function() {
});
it('can configure specs to throw errors on expectation failures', function() {
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
spyOn(jasmineUnderTest, 'Spec').and.callThrough();
env.it('foo', function() {});
@@ -100,7 +100,7 @@ describe('Env', function() {
});
it('can configure suites to throw errors on expectation failures', function() {
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
spyOn(jasmineUnderTest, 'Suite');
env.describe('foo', function() {});
@@ -112,12 +112,15 @@ describe('Env', function() {
});
it('ignores configuration properties that are present but undefined', function() {
spyOn(env, 'deprecated');
var initialConfig = {
random: true,
seed: '123',
failFast: true,
failSpecWithNoExpectations: true,
oneFailurePerSpec: true,
stopSpecOnExpectationFailure: true,
stopOnSpecFailure: true,
hideDisabled: true
};
env.configure(initialConfig);
@@ -128,6 +131,8 @@ describe('Env', function() {
failFast: undefined,
failSpecWithNoExpectations: undefined,
oneFailurePerSpec: undefined,
stopSpecOnExpectationFailure: undefined,
stopOnSpecFailure: undefined,
hideDisabled: undefined
});
@@ -136,6 +141,89 @@ describe('Env', function() {
);
});
it('sets stopOnSpecFailure when failFast is set, and vice versa', function() {
spyOn(env, 'deprecated');
env.configure({ failFast: true });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
failFast: true,
stopOnSpecFailure: true
})
);
env.configure({ stopOnSpecFailure: false });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
failFast: false,
stopOnSpecFailure: false
})
);
});
it('rejects a single call that sets stopOnSpecFailure and failFast to different values', function() {
spyOn(env, 'deprecated');
expect(function() {
env.configure({ failFast: true, stopOnSpecFailure: false });
}).toThrowError(
'stopOnSpecFailure and failFast are aliases for each ' +
"other. Don't set failFast if you also set stopOnSpecFailure."
);
});
it('deprecates the failFast config property', function() {
spyOn(env, 'deprecated');
env.configure({ failFast: true });
expect(env.deprecated).toHaveBeenCalledWith(
'The `failFast` config property is deprecated and will be removed in a ' +
'future version of Jasmine. Please use `stopOnSpecFailure` instead.',
{ ignoreRunnable: true }
);
});
it('sets stopSpecOnExpectationFailure when oneFailurePerSpec is set, and vice versa', function() {
spyOn(env, 'deprecated');
env.configure({ oneFailurePerSpec: true });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
oneFailurePerSpec: true,
stopSpecOnExpectationFailure: true
})
);
env.configure({ stopSpecOnExpectationFailure: false });
expect(env.configuration()).toEqual(
jasmine.objectContaining({
oneFailurePerSpec: false,
stopSpecOnExpectationFailure: false
})
);
});
it('rejects a single call that sets stopSpecOnExpectationFailure and oneFailurePerSpec to different values', function() {
spyOn(env, 'deprecated');
expect(function() {
env.configure({
oneFailurePerSpec: true,
stopSpecOnExpectationFailure: false
});
}).toThrowError(
'stopSpecOnExpectationFailure and oneFailurePerSpec are ' +
"aliases for each other. Don't set oneFailurePerSpec if you also set " +
'stopSpecOnExpectationFailure.'
);
});
it('deprecates the oneFailurePerSpec config property', function() {
spyOn(env, 'deprecated');
env.configure({ oneFailurePerSpec: true });
expect(env.deprecated).toHaveBeenCalledWith(
'The `oneFailurePerSpec` config property is deprecated and will be ' +
'removed in a future version of Jasmine. Please use ' +
'`stopSpecOnExpectationFailure` instead.',
{ ignoreRunnable: true }
);
});
describe('promise library', function() {
it('can be configured without a custom library', function() {
env.configure({});

View File

@@ -792,7 +792,7 @@ describe('spec running', function() {
});
});
describe('When throwOnExpectationFailure is set', function() {
describe('When stopSpecOnExpectationFailure is set', function() {
it('skips to cleanup functions after an error', function(done) {
var actions = [];
@@ -821,7 +821,7 @@ describe('spec running', function() {
});
});
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
env.execute(null, function() {
expect(actions).toEqual([
@@ -852,7 +852,7 @@ describe('spec running', function() {
});
});
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
env.execute(null, function() {
expect(actions).toEqual(['beforeEach', 'afterEach']);
@@ -877,7 +877,7 @@ describe('spec running', function() {
});
});
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
env.execute(null, function() {
expect(actions).toEqual(['beforeEach', 'afterEach']);
@@ -886,9 +886,10 @@ describe('spec running', function() {
});
});
describe('when stopOnSpecFailure is on', function() {
function behavesLikeStopOnSpecFailureIsOn(configureFn) {
it('does not run further specs when one fails', function(done) {
var actions = [];
var actions = [],
config;
env.describe('wrapper', function() {
env.it('fails', function() {
@@ -903,12 +904,26 @@ describe('spec running', function() {
});
});
env.configure({ random: false, failFast: true });
env.configure({ random: false });
configureFn(env);
env.execute(null, function() {
expect(actions).toEqual(['fails']);
done();
});
});
}
describe('when failFast is on', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
spyOn(env, 'deprecated');
env.configure({ failFast: true });
});
});
describe('when stopOnSpecFailure is on', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
env.configure({ stopOnSpecFailure: true });
});
});
});

View File

@@ -785,7 +785,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ failFast: true });
env.configure({ stopOnSpecFailure: true });
reporter.initialize();
reporter.jasmineDone({});
@@ -839,7 +839,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ failFast: true });
env.configure({ stopOnSpecFailure: true });
reporter.initialize();
reporter.jasmineDone({});
@@ -891,7 +891,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
reporter.initialize();
reporter.jasmineDone({});
@@ -945,7 +945,7 @@ describe('HtmlReporter', function() {
}
});
env.configure({ oneFailurePerSpec: true });
env.configure({ stopSpecOnExpectationFailure: true });
reporter.initialize();
reporter.jasmineDone({});

View File

@@ -65,8 +65,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopOnSpecFailure` config property instead.
*/
failFast: false,
/**
* Whether to stop execution of the suite after the first spec failure
* @name Configuration#stopOnSpecFailure
* @since 3.9.0
* @type Boolean
* @default false
*/
stopOnSpecFailure: false,
/**
* Whether to fail the spec if it ran no expectations. By default
* a spec that ran no expectations is reported as passed. Setting this
@@ -83,8 +92,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0
* @type Boolean
* @default false
* @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
*/
oneFailurePerSpec: false,
/**
* Whether to cause specs to only have one expectation failure.
* @name Configuration#stopSpecOnExpectationFailure
* @since 3.3.0
* @type Boolean
* @default false
*/
stopSpecOnExpectationFailure: false,
/**
* A function that takes a spec and returns true if it should be executed
* or false if it should be skipped.
@@ -184,9 +202,7 @@ getJasmineRequireObj().Env = function(j$) {
this.configure = function(configuration) {
var booleanProps = [
'random',
'failFast',
'failSpecWithNoExpectations',
'oneFailurePerSpec',
'hideDisabled'
];
@@ -196,6 +212,70 @@ getJasmineRequireObj().Env = function(j$) {
}
});
if (typeof configuration.failFast !== 'undefined') {
// We can't unconditionally issue a warning here because then users who
// get the configuration from Jasmine, modify it, and pass it back would
// see the warning.
if (configuration.failFast !== config.failFast) {
this.deprecated(
'The `failFast` config property is deprecated and will be removed ' +
'in a future version of Jasmine. Please use `stopOnSpecFailure` ' +
'instead.',
{ ignoreRunnable: true }
);
}
if (typeof configuration.stopOnSpecFailure !== 'undefined') {
if (configuration.stopOnSpecFailure !== configuration.failFast) {
throw new Error(
'stopOnSpecFailure and failFast are aliases for ' +
"each other. Don't set failFast if you also set stopOnSpecFailure."
);
}
}
config.failFast = configuration.failFast;
config.stopOnSpecFailure = configuration.failFast;
} else if (typeof configuration.stopOnSpecFailure !== 'undefined') {
config.failFast = configuration.stopOnSpecFailure;
config.stopOnSpecFailure = configuration.stopOnSpecFailure;
}
if (typeof configuration.oneFailurePerSpec !== 'undefined') {
// We can't unconditionally issue a warning here because then users who
// get the configuration from Jasmine, modify it, and pass it back would
// see the warning.
if (configuration.oneFailurePerSpec !== config.oneFailurePerSpec) {
this.deprecated(
'The `oneFailurePerSpec` config property is deprecated and will be ' +
'removed in a future version of Jasmine. Please use ' +
'`stopSpecOnExpectationFailure` instead.',
{ ignoreRunnable: true }
);
}
if (typeof configuration.stopSpecOnExpectationFailure !== 'undefined') {
if (
configuration.stopSpecOnExpectationFailure !==
configuration.oneFailurePerSpec
) {
throw new Error(
'stopSpecOnExpectationFailure and oneFailurePerSpec are aliases for ' +
"each other. Don't set oneFailurePerSpec if you also set stopSpecOnExpectationFailure."
);
}
}
config.oneFailurePerSpec = configuration.oneFailurePerSpec;
config.stopSpecOnExpectationFailure = configuration.oneFailurePerSpec;
} else if (
typeof configuration.stopSpecOnExpectationFailure !== 'undefined'
) {
config.oneFailurePerSpec = configuration.stopSpecOnExpectationFailure;
config.stopSpecOnExpectationFailure =
configuration.stopSpecOnExpectationFailure;
}
if (configuration.specFilter) {
config.specFilter = configuration.specFilter;
}
@@ -507,9 +587,9 @@ getJasmineRequireObj().Env = function(j$) {
var queueRunnerFactory = function(options, args) {
var failFast = false;
if (options.isLeaf) {
failFast = config.oneFailurePerSpec;
failFast = config.stopSpecOnExpectationFailure;
} else if (!options.isReporter) {
failFast = config.failFast;
failFast = config.stopOnSpecFailure;
}
options.clearStack = options.clearStack || clearStack;
options.timeout = {

View File

@@ -538,17 +538,20 @@ jasmineRequire.HtmlReporter = function(j$) {
);
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
failFastCheckbox.checked = config.failFast;
failFastCheckbox.checked = config.stopOnSpecFailure;
failFastCheckbox.onclick = function() {
navigateWithNewParam('failFast', !config.failFast);
navigateWithNewParam('failFast', !config.stopOnSpecFailure);
};
var throwCheckbox = optionsMenuDom.querySelector(
'#jasmine-throw-failures'
);
throwCheckbox.checked = config.oneFailurePerSpec;
throwCheckbox.checked = config.stopSpecOnExpectationFailure;
throwCheckbox.onclick = function() {
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec);
navigateWithNewParam(
'oneFailurePerSpec',
!config.stopSpecOnExpectationFailure
);
};
var randomCheckbox = optionsMenuDom.querySelector(