Merge branch 'main' into 3.99

This commit is contained in:
Steve Gravrock
2021-07-31 08:15:29 -07:00
7 changed files with 251 additions and 80 deletions
+7 -4
View File
@@ -569,17 +569,20 @@ jasmineRequire.HtmlReporter = function(j$) {
); );
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast'); var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
failFastCheckbox.checked = config.failFast; failFastCheckbox.checked = config.stopOnSpecFailure;
failFastCheckbox.onclick = function() { failFastCheckbox.onclick = function() {
navigateWithNewParam('failFast', !config.failFast); navigateWithNewParam('failFast', !config.stopOnSpecFailure);
}; };
var throwCheckbox = optionsMenuDom.querySelector( var throwCheckbox = optionsMenuDom.querySelector(
'#jasmine-throw-failures' '#jasmine-throw-failures'
); );
throwCheckbox.checked = config.oneFailurePerSpec; throwCheckbox.checked = config.stopSpecOnExpectationFailure;
throwCheckbox.onclick = function() { throwCheckbox.onclick = function() {
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec); navigateWithNewParam(
'oneFailurePerSpec',
!config.stopSpecOnExpectationFailure
);
}; };
var randomCheckbox = optionsMenuDom.querySelector( var randomCheckbox = optionsMenuDom.querySelector(
+74 -19
View File
@@ -1103,8 +1103,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0 * @since 3.3.0
* @type Boolean * @type Boolean
* @default false * @default false
* @deprecated Use the `stopOnSpecFailure` config property instead.
*/ */
failFast: false, 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 * Whether to fail the spec if it ran no expectations. By default
* a spec that ran no expectations is reported as passed. Setting this * a spec that ran no expectations is reported as passed. Setting this
@@ -1121,8 +1130,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0 * @since 3.3.0
* @type Boolean * @type Boolean
* @default false * @default false
* @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
*/ */
oneFailurePerSpec: false, 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 * A function that takes a spec and returns true if it should be executed
* or false if it should be skipped. * or false if it should be skipped.
@@ -1222,9 +1240,7 @@ getJasmineRequireObj().Env = function(j$) {
this.configure = function(configuration) { this.configure = function(configuration) {
var booleanProps = [ var booleanProps = [
'random', 'random',
'failFast',
'failSpecWithNoExpectations', 'failSpecWithNoExpectations',
'oneFailurePerSpec',
'hideDisabled' 'hideDisabled'
]; ];
@@ -1234,6 +1250,46 @@ getJasmineRequireObj().Env = function(j$) {
} }
}); });
if (typeof configuration.failFast !== 'undefined') {
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') {
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) { if (configuration.specFilter) {
config.specFilter = configuration.specFilter; config.specFilter = configuration.specFilter;
} }
@@ -1570,13 +1626,13 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.3.0 * @since 2.3.0
* @function * @function
* @param {Boolean} value Whether to throw when a expectation fails * @param {Boolean} value Whether to throw when a expectation fails
* @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure} * @deprecated Use the `stopSpecOnExpectationFailure` option with {@link Env#configure}
*/ */
this.throwOnExpectationFailure = function(value) { this.throwOnExpectationFailure = function(value) {
this.deprecated( this.deprecated(
'Setting throwOnExpectationFailure directly on Env is deprecated ' + 'Setting throwOnExpectationFailure directly on Env is deprecated and ' +
'and will be removed in a future version of Jasmine. Please use the ' + 'will be removed in a future version of Jasmine. Please use the ' +
'oneFailurePerSpec option in `configure` instead.', 'stopSpecOnExpectationFailure option in `configure`.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
this.configure({ oneFailurePerSpec: !!value }); this.configure({ oneFailurePerSpec: !!value });
@@ -1584,10 +1640,9 @@ getJasmineRequireObj().Env = function(j$) {
this.throwingExpectationFailures = function() { this.throwingExpectationFailures = function() {
this.deprecated( this.deprecated(
'Getting throwingExpectationFailures directly from Env is ' + 'Getting throwingExpectationFailures directly from Env is deprecated ' +
'deprecated and will be removed in a future version of Jasmine. ' + 'and will be removed in a future version of Jasmine. Please check ' +
'Please check the oneFailurePerSpec option from `configuration` ' + 'the stopSpecOnExpectationFailure option from `configuration`.',
'instead.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
return config.oneFailurePerSpec; return config.oneFailurePerSpec;
@@ -1599,23 +1654,23 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.7.0 * @since 2.7.0
* @function * @function
* @param {Boolean} value Whether to stop suite execution when a spec fails * @param {Boolean} value Whether to stop suite execution when a spec fails
* @deprecated Use the `failFast` option with {@link Env#configure} * @deprecated Use the `stopOnSpecFailure` option with {@link Env#configure}
*/ */
this.stopOnSpecFailure = function(value) { this.stopOnSpecFailure = function(value) {
this.deprecated( this.deprecated(
'Setting stopOnSpecFailure directly is deprecated and will be ' + 'Setting stopOnSpecFailure directly is deprecated and will be ' +
'removed in a future version of Jasmine. Please use the failFast ' + 'removed in a future version of Jasmine. Please use the ' +
'option in `configure` instead.', 'stopOnSpecFailure option in `configure`.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
this.configure({ failFast: !!value }); this.configure({ stopOnSpecFailure: !!value });
}; };
this.stoppingOnSpecFailure = function() { this.stoppingOnSpecFailure = function() {
this.deprecated( this.deprecated(
'Getting stoppingOnSpecFailure directly from Env is deprecated ' + 'Getting stoppingOnSpecFailure directly from Env is deprecated and ' +
'and will be removed in a future version of Jasmine. Please check ' + 'will be removed in a future version of Jasmine. Please check the ' +
'the failFast option from `configuration` instead.', 'stopOnSpecFailure option from `configuration`.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
return config.failFast; return config.failFast;
@@ -1726,9 +1781,9 @@ getJasmineRequireObj().Env = function(j$) {
var queueRunnerFactory = function(options, args) { var queueRunnerFactory = function(options, args) {
var failFast = false; var failFast = false;
if (options.isLeaf) { if (options.isLeaf) {
failFast = config.oneFailurePerSpec; failFast = config.stopSpecOnExpectationFailure;
} else if (!options.isReporter) { } else if (!options.isReporter) {
failFast = config.failFast; failFast = config.stopOnSpecFailure;
} }
options.clearStack = options.clearStack || clearStack; options.clearStack = options.clearStack || clearStack;
options.timeout = { options.timeout = {
+62
View File
@@ -286,6 +286,8 @@ describe('Env', function() {
failFast: true, failFast: true,
failSpecWithNoExpectations: true, failSpecWithNoExpectations: true,
oneFailurePerSpec: true, oneFailurePerSpec: true,
stopSpecOnExpectationFailure: true,
stopOnSpecFailure: true,
hideDisabled: true hideDisabled: true
}; };
env.configure(initialConfig); env.configure(initialConfig);
@@ -296,6 +298,8 @@ describe('Env', function() {
failFast: undefined, failFast: undefined,
failSpecWithNoExpectations: undefined, failSpecWithNoExpectations: undefined,
oneFailurePerSpec: undefined, oneFailurePerSpec: undefined,
stopSpecOnExpectationFailure: undefined,
stopOnSpecFailure: undefined,
hideDisabled: undefined hideDisabled: undefined
}); });
@@ -304,6 +308,64 @@ describe('Env', function() {
); );
}); });
it('sets stopOnSpecFailure when failFast is set, and vice versa', function() {
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() {
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('sets stopSpecOnExpectationFailure when oneFailurePerSpec is set, and vice versa', function() {
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() {
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.'
);
});
describe('promise library', function() { describe('promise library', function() {
it('can be configured without a custom library', function() { it('can be configured without a custom library', function() {
env.configure({}); env.configure({});
+23 -30
View File
@@ -987,35 +987,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) { it('does not run further specs when one fails', function(done) {
var actions = []; var actions = [],
config;
env.describe('wrapper', function() {
env.it('fails', function() {
actions.push('fails');
env.expect(1).toBe(2);
});
});
env.describe('holder', function() {
env.it('does not run', function() {
actions.push('does not run');
});
});
env.configure({ random: false, failFast: true });
env.execute(null, function() {
expect(actions).toEqual(['fails']);
done();
});
});
it('does not run further specs when one fails when configured with deprecated option', function(done) {
var actions = [];
spyOn(env, 'deprecated');
env.describe('wrapper', function() { env.describe('wrapper', function() {
env.it('fails', function() { env.it('fails', function() {
@@ -1031,13 +1006,31 @@ describe('spec running', function() {
}); });
env.configure({ random: false }); env.configure({ random: false });
env.stopOnSpecFailure(true); configureFn(env);
env.execute(null, function() { env.execute(null, function() {
expect(actions).toEqual(['fails']); expect(actions).toEqual(['fails']);
expect(env.deprecated).toHaveBeenCalled();
done(); done();
}); });
}); });
}
describe('when failFast is on', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
env.configure({ failFast: true });
});
});
describe('when stopOnSpecFailure is on', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
env.configure({ stopOnSpecFailure: true });
});
});
describe('when stopOnSpecFailure is enabled via the deprecated method', function() {
behavesLikeStopOnSpecFailureIsOn(function(env) {
spyOn(env, 'deprecated');
env.stopOnSpecFailure(true);
});
}); });
}); });
+4 -4
View File
@@ -785,7 +785,7 @@ describe('HtmlReporter', function() {
} }
}); });
env.configure({ failFast: true }); env.configure({ stopOnSpecFailure: true });
reporter.initialize(); reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
@@ -839,7 +839,7 @@ describe('HtmlReporter', function() {
} }
}); });
env.configure({ failFast: true }); env.configure({ stopOnSpecFailure: true });
reporter.initialize(); reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
@@ -891,7 +891,7 @@ describe('HtmlReporter', function() {
} }
}); });
env.configure({ oneFailurePerSpec: true }); env.configure({ stopSpecOnExpectationFailure: true });
reporter.initialize(); reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
@@ -945,7 +945,7 @@ describe('HtmlReporter', function() {
} }
}); });
env.configure({ oneFailurePerSpec: true }); env.configure({ stopSpecOnExpectationFailure: true });
reporter.initialize(); reporter.initialize();
reporter.jasmineDone({}); reporter.jasmineDone({});
+74 -19
View File
@@ -65,8 +65,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0 * @since 3.3.0
* @type Boolean * @type Boolean
* @default false * @default false
* @deprecated Use the `stopOnSpecFailure` config property instead.
*/ */
failFast: false, 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 * Whether to fail the spec if it ran no expectations. By default
* a spec that ran no expectations is reported as passed. Setting this * a spec that ran no expectations is reported as passed. Setting this
@@ -83,8 +92,17 @@ getJasmineRequireObj().Env = function(j$) {
* @since 3.3.0 * @since 3.3.0
* @type Boolean * @type Boolean
* @default false * @default false
* @deprecated Use the `stopSpecOnExpectationFailure` config property instead.
*/ */
oneFailurePerSpec: false, 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 * A function that takes a spec and returns true if it should be executed
* or false if it should be skipped. * or false if it should be skipped.
@@ -184,9 +202,7 @@ getJasmineRequireObj().Env = function(j$) {
this.configure = function(configuration) { this.configure = function(configuration) {
var booleanProps = [ var booleanProps = [
'random', 'random',
'failFast',
'failSpecWithNoExpectations', 'failSpecWithNoExpectations',
'oneFailurePerSpec',
'hideDisabled' 'hideDisabled'
]; ];
@@ -196,6 +212,46 @@ getJasmineRequireObj().Env = function(j$) {
} }
}); });
if (typeof configuration.failFast !== 'undefined') {
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') {
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) { if (configuration.specFilter) {
config.specFilter = configuration.specFilter; config.specFilter = configuration.specFilter;
} }
@@ -532,13 +588,13 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.3.0 * @since 2.3.0
* @function * @function
* @param {Boolean} value Whether to throw when a expectation fails * @param {Boolean} value Whether to throw when a expectation fails
* @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure} * @deprecated Use the `stopSpecOnExpectationFailure` option with {@link Env#configure}
*/ */
this.throwOnExpectationFailure = function(value) { this.throwOnExpectationFailure = function(value) {
this.deprecated( this.deprecated(
'Setting throwOnExpectationFailure directly on Env is deprecated ' + 'Setting throwOnExpectationFailure directly on Env is deprecated and ' +
'and will be removed in a future version of Jasmine. Please use the ' + 'will be removed in a future version of Jasmine. Please use the ' +
'oneFailurePerSpec option in `configure` instead.', 'stopSpecOnExpectationFailure option in `configure`.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
this.configure({ oneFailurePerSpec: !!value }); this.configure({ oneFailurePerSpec: !!value });
@@ -546,10 +602,9 @@ getJasmineRequireObj().Env = function(j$) {
this.throwingExpectationFailures = function() { this.throwingExpectationFailures = function() {
this.deprecated( this.deprecated(
'Getting throwingExpectationFailures directly from Env is ' + 'Getting throwingExpectationFailures directly from Env is deprecated ' +
'deprecated and will be removed in a future version of Jasmine. ' + 'and will be removed in a future version of Jasmine. Please check ' +
'Please check the oneFailurePerSpec option from `configuration` ' + 'the stopSpecOnExpectationFailure option from `configuration`.',
'instead.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
return config.oneFailurePerSpec; return config.oneFailurePerSpec;
@@ -561,23 +616,23 @@ getJasmineRequireObj().Env = function(j$) {
* @since 2.7.0 * @since 2.7.0
* @function * @function
* @param {Boolean} value Whether to stop suite execution when a spec fails * @param {Boolean} value Whether to stop suite execution when a spec fails
* @deprecated Use the `failFast` option with {@link Env#configure} * @deprecated Use the `stopOnSpecFailure` option with {@link Env#configure}
*/ */
this.stopOnSpecFailure = function(value) { this.stopOnSpecFailure = function(value) {
this.deprecated( this.deprecated(
'Setting stopOnSpecFailure directly is deprecated and will be ' + 'Setting stopOnSpecFailure directly is deprecated and will be ' +
'removed in a future version of Jasmine. Please use the failFast ' + 'removed in a future version of Jasmine. Please use the ' +
'option in `configure` instead.', 'stopOnSpecFailure option in `configure`.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
this.configure({ failFast: !!value }); this.configure({ stopOnSpecFailure: !!value });
}; };
this.stoppingOnSpecFailure = function() { this.stoppingOnSpecFailure = function() {
this.deprecated( this.deprecated(
'Getting stoppingOnSpecFailure directly from Env is deprecated ' + 'Getting stoppingOnSpecFailure directly from Env is deprecated and ' +
'and will be removed in a future version of Jasmine. Please check ' + 'will be removed in a future version of Jasmine. Please check the ' +
'the failFast option from `configuration` instead.', 'stopOnSpecFailure option from `configuration`.',
{ ignoreRunnable: true } { ignoreRunnable: true }
); );
return config.failFast; return config.failFast;
@@ -688,9 +743,9 @@ getJasmineRequireObj().Env = function(j$) {
var queueRunnerFactory = function(options, args) { var queueRunnerFactory = function(options, args) {
var failFast = false; var failFast = false;
if (options.isLeaf) { if (options.isLeaf) {
failFast = config.oneFailurePerSpec; failFast = config.stopSpecOnExpectationFailure;
} else if (!options.isReporter) { } else if (!options.isReporter) {
failFast = config.failFast; failFast = config.stopOnSpecFailure;
} }
options.clearStack = options.clearStack || clearStack; options.clearStack = options.clearStack || clearStack;
options.timeout = { options.timeout = {
+7 -4
View File
@@ -538,17 +538,20 @@ jasmineRequire.HtmlReporter = function(j$) {
); );
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast'); var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
failFastCheckbox.checked = config.failFast; failFastCheckbox.checked = config.stopOnSpecFailure;
failFastCheckbox.onclick = function() { failFastCheckbox.onclick = function() {
navigateWithNewParam('failFast', !config.failFast); navigateWithNewParam('failFast', !config.stopOnSpecFailure);
}; };
var throwCheckbox = optionsMenuDom.querySelector( var throwCheckbox = optionsMenuDom.querySelector(
'#jasmine-throw-failures' '#jasmine-throw-failures'
); );
throwCheckbox.checked = config.oneFailurePerSpec; throwCheckbox.checked = config.stopSpecOnExpectationFailure;
throwCheckbox.onclick = function() { throwCheckbox.onclick = function() {
navigateWithNewParam('oneFailurePerSpec', !config.oneFailurePerSpec); navigateWithNewParam(
'oneFailurePerSpec',
!config.stopSpecOnExpectationFailure
);
}; };
var randomCheckbox = optionsMenuDom.querySelector( var randomCheckbox = optionsMenuDom.querySelector(