Resolve the promise returned by Env#execute to the overall status
This commit is contained in:
@@ -1832,19 +1832,21 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
* the second parameter. To specify a completion callback but not a list of
|
* the second parameter. To specify a completion callback but not a list of
|
||||||
* specs/suites to run, pass null or undefined as the first parameter.
|
* specs/suites to run, pass null or undefined as the first parameter.
|
||||||
*
|
*
|
||||||
* execute should not be called more than once.
|
* execute should not be called more than once unless the env has been
|
||||||
|
* configured with `{autoCleanClosures: false}`.
|
||||||
*
|
*
|
||||||
* If the environment supports promises, execute will return a promise that
|
* If the environment supports promises, execute will return a promise that
|
||||||
* is resolved after the suite finishes executing. The promise will be
|
* is resolved after the suite finishes executing. The promise will be
|
||||||
* resolved (not rejected) as long as the suite runs to completion. Use a
|
* resolved (not rejected) to the suite's overall status as long as the
|
||||||
* {@link Reporter} to determine whether or not the suite passed.
|
* suite runs to completion. To determine whether the suite passed, check
|
||||||
|
* the value that the promise resolves to or use a {@link Reporter}.
|
||||||
*
|
*
|
||||||
* @name Env#execute
|
* @name Env#execute
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @function
|
* @function
|
||||||
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
|
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
|
||||||
* @param {Function=} onComplete Function that will be called after all specs have run
|
* @param {Function=} onComplete Function that will be called after all specs have run
|
||||||
* @return {Promise<undefined>}
|
* @return {Promise<string>}
|
||||||
*/
|
*/
|
||||||
this.execute = function(runnablesToRun, onComplete) {
|
this.execute = function(runnablesToRun, onComplete) {
|
||||||
if (this._executedBefore) {
|
if (this._executedBefore) {
|
||||||
@@ -1910,12 +1912,12 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
jasmineTimer.start();
|
jasmineTimer.start();
|
||||||
|
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
runAll(function() {
|
runAll(function(overallStatus) {
|
||||||
if (onComplete) {
|
if (onComplete) {
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve(overallStatus);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1975,7 +1977,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
failedExpectations: topSuite.result.failedExpectations,
|
failedExpectations: topSuite.result.failedExpectations,
|
||||||
deprecationWarnings: topSuite.result.deprecationWarnings
|
deprecationWarnings: topSuite.result.deprecationWarnings
|
||||||
},
|
},
|
||||||
done
|
function() {
|
||||||
|
done(overallStatus);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,9 @@ describe('Custom Spy Strategies (Integration)', function() {
|
|||||||
env.cleanup_();
|
env.cleanup_();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows adding more strategies local to a suite', function(done) {
|
it('allows adding more strategies local to a suite', async function() {
|
||||||
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
||||||
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
||||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
|
||||||
|
|
||||||
env.describe('suite defining a custom spy strategy', function() {
|
env.describe('suite defining a custom spy strategy', function() {
|
||||||
env.beforeAll(function() {
|
env.beforeAll(function() {
|
||||||
@@ -32,20 +31,13 @@ describe('Custom Spy Strategies (Integration)', function() {
|
|||||||
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
|
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
function expectations() {
|
const overallStatus = await env.execute();
|
||||||
var result = jasmineDone.calls.argsFor(0)[0];
|
expect(overallStatus).toEqual('passed');
|
||||||
expect(result.overallStatus).toEqual('passed');
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: jasmineDone });
|
|
||||||
env.execute(null, expectations);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows adding more strategies local to a spec', function(done) {
|
it('allows adding more strategies local to a spec', async function() {
|
||||||
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
||||||
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
||||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
|
||||||
|
|
||||||
env.it('spec defining a custom spy strategy', function() {
|
env.it('spec defining a custom spy strategy', function() {
|
||||||
env.addSpyStrategy('frobnicate', strategy);
|
env.addSpyStrategy('frobnicate', strategy);
|
||||||
@@ -59,20 +51,13 @@ describe('Custom Spy Strategies (Integration)', function() {
|
|||||||
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
|
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
function expectations() {
|
const overallStatus = await env.execute();
|
||||||
var result = jasmineDone.calls.argsFor(0)[0];
|
expect(overallStatus).toEqual('passed');
|
||||||
expect(result.overallStatus).toEqual('passed');
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: jasmineDone });
|
|
||||||
env.execute(null, expectations);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows using custom strategies on a per-argument basis', function(done) {
|
it('allows using custom strategies on a per-argument basis', async function() {
|
||||||
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
var plan = jasmine.createSpy('custom strategy plan').and.returnValue(42);
|
||||||
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
var strategy = jasmine.createSpy('custom strategy').and.returnValue(plan);
|
||||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
|
||||||
|
|
||||||
env.it('spec defining a custom spy strategy', function() {
|
env.it('spec defining a custom spy strategy', function() {
|
||||||
env.addSpyStrategy('frobnicate', strategy);
|
env.addSpyStrategy('frobnicate', strategy);
|
||||||
@@ -92,23 +77,16 @@ describe('Custom Spy Strategies (Integration)', function() {
|
|||||||
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
|
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
function expectations() {
|
const overallStatus = await env.execute();
|
||||||
var result = jasmineDone.calls.argsFor(0)[0];
|
expect(overallStatus).toEqual('passed');
|
||||||
expect(result.overallStatus).toEqual('passed');
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: jasmineDone });
|
|
||||||
env.execute(null, expectations);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows multiple custom strategies to be used', function(done) {
|
it('allows multiple custom strategies to be used', async function() {
|
||||||
var plan1 = jasmine.createSpy('plan 1').and.returnValue(42),
|
var plan1 = jasmine.createSpy('plan 1').and.returnValue(42),
|
||||||
strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1),
|
strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1),
|
||||||
plan2 = jasmine.createSpy('plan 2').and.returnValue(24),
|
plan2 = jasmine.createSpy('plan 2').and.returnValue(24),
|
||||||
strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2),
|
strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2),
|
||||||
specDone = jasmine.createSpy('specDone'),
|
specDone = jasmine.createSpy('specDone');
|
||||||
jasmineDone = jasmine.createSpy('jasmineDone');
|
|
||||||
|
|
||||||
env.beforeEach(function() {
|
env.beforeEach(function() {
|
||||||
env.addSpyStrategy('frobnicate', strategy1);
|
env.addSpyStrategy('frobnicate', strategy1);
|
||||||
@@ -133,14 +111,9 @@ describe('Custom Spy Strategies (Integration)', function() {
|
|||||||
expect(plan2).toHaveBeenCalled();
|
expect(plan2).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
function expectations() {
|
env.addReporter({ specDone: specDone });
|
||||||
var result = jasmineDone.calls.argsFor(0)[0];
|
const overallStatus = await env.execute();
|
||||||
expect(result.overallStatus).toEqual('passed');
|
expect(overallStatus).toEqual('passed');
|
||||||
expect(specDone.calls.count()).toBe(2);
|
expect(specDone.calls.count()).toBe(2);
|
||||||
done();
|
|
||||||
}
|
|
||||||
|
|
||||||
env.addReporter({ jasmineDone: jasmineDone, specDone: specDone });
|
|
||||||
env.execute(null, expectations);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ describe('Default Spy Strategy (Integration)', function() {
|
|||||||
env.cleanup_();
|
env.cleanup_();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows defining a default spy strategy', function(done) {
|
it('allows defining a default spy strategy', async function() {
|
||||||
env.describe('suite with default strategy', function() {
|
env.describe('suite with default strategy', function() {
|
||||||
env.beforeEach(function() {
|
env.beforeEach(function() {
|
||||||
env.setDefaultSpyStrategy(function(and) {
|
env.setDefaultSpyStrategy(function(and) {
|
||||||
@@ -29,18 +29,11 @@ describe('Default Spy Strategy (Integration)', function() {
|
|||||||
expect(spy()).toBeUndefined();
|
expect(spy()).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
function expectations() {
|
const overallStatus = await env.execute();
|
||||||
var result = jasmineDone.calls.argsFor(0)[0];
|
expect(overallStatus).toEqual('passed');
|
||||||
expect(result.overallStatus).toEqual('passed');
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
|
|
||||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
|
||||||
env.addReporter({ jasmineDone: jasmineDone });
|
|
||||||
env.execute(null, expectations);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the default spy strategy defined when the spy is created', function(done) {
|
it('uses the default spy strategy defined when the spy is created', async function() {
|
||||||
env.it('spec', function() {
|
env.it('spec', function() {
|
||||||
var a = env.createSpy('a');
|
var a = env.createSpy('a');
|
||||||
env.setDefaultSpyStrategy(function(and) {
|
env.setDefaultSpyStrategy(function(and) {
|
||||||
@@ -67,14 +60,7 @@ describe('Default Spy Strategy (Integration)', function() {
|
|||||||
expect(d.and.isConfigured()).toBe(false);
|
expect(d.and.isConfigured()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
function expectations() {
|
const overallStatus = await env.execute();
|
||||||
var result = jasmineDone.calls.argsFor(0)[0];
|
expect(overallStatus).toEqual('passed');
|
||||||
expect(result.overallStatus).toEqual('passed');
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
|
|
||||||
var jasmineDone = jasmine.createSpy('jasmineDone');
|
|
||||||
env.addReporter({ jasmineDone: jasmineDone });
|
|
||||||
env.execute(null, expectations);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3229,14 +3229,14 @@ describe('Env integration', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is resolved even if specs fail', function() {
|
it('is resolved to the overall status', function() {
|
||||||
env.describe('suite', function() {
|
env.describe('suite', function() {
|
||||||
env.it('spec', function() {
|
env.it('spec', function() {
|
||||||
env.expect(true).toBe(false);
|
env.expect(true).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectAsync(env.execute(null)).toBeResolved();
|
return expectAsync(env.execute(null)).toBeResolvedTo('failed');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -669,19 +669,21 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
* the second parameter. To specify a completion callback but not a list of
|
* the second parameter. To specify a completion callback but not a list of
|
||||||
* specs/suites to run, pass null or undefined as the first parameter.
|
* specs/suites to run, pass null or undefined as the first parameter.
|
||||||
*
|
*
|
||||||
* execute should not be called more than once.
|
* execute should not be called more than once unless the env has been
|
||||||
|
* configured with `{autoCleanClosures: false}`.
|
||||||
*
|
*
|
||||||
* If the environment supports promises, execute will return a promise that
|
* If the environment supports promises, execute will return a promise that
|
||||||
* is resolved after the suite finishes executing. The promise will be
|
* is resolved after the suite finishes executing. The promise will be
|
||||||
* resolved (not rejected) as long as the suite runs to completion. Use a
|
* resolved (not rejected) to the suite's overall status as long as the
|
||||||
* {@link Reporter} to determine whether or not the suite passed.
|
* suite runs to completion. To determine whether the suite passed, check
|
||||||
|
* the value that the promise resolves to or use a {@link Reporter}.
|
||||||
*
|
*
|
||||||
* @name Env#execute
|
* @name Env#execute
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
* @function
|
* @function
|
||||||
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
|
* @param {(string[])=} runnablesToRun IDs of suites and/or specs to run
|
||||||
* @param {Function=} onComplete Function that will be called after all specs have run
|
* @param {Function=} onComplete Function that will be called after all specs have run
|
||||||
* @return {Promise<undefined>}
|
* @return {Promise<string>}
|
||||||
*/
|
*/
|
||||||
this.execute = function(runnablesToRun, onComplete) {
|
this.execute = function(runnablesToRun, onComplete) {
|
||||||
if (this._executedBefore) {
|
if (this._executedBefore) {
|
||||||
@@ -747,12 +749,12 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
jasmineTimer.start();
|
jasmineTimer.start();
|
||||||
|
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
runAll(function() {
|
runAll(function(overallStatus) {
|
||||||
if (onComplete) {
|
if (onComplete) {
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve(overallStatus);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -812,7 +814,9 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
failedExpectations: topSuite.result.failedExpectations,
|
failedExpectations: topSuite.result.failedExpectations,
|
||||||
deprecationWarnings: topSuite.result.deprecationWarnings
|
deprecationWarnings: topSuite.result.deprecationWarnings
|
||||||
},
|
},
|
||||||
done
|
function() {
|
||||||
|
done(overallStatus);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user