Resolve the execute() promise to the entire JasmineDoneInfo

This matches jasmine-npm.
This commit is contained in:
Steve Gravrock
2021-12-09 18:18:36 -08:00
parent b37d989f13
commit f1cf6ee419
5 changed files with 47 additions and 44 deletions

View File

@@ -1900,12 +1900,12 @@ getJasmineRequireObj().Env = function(j$) {
jasmineTimer.start();
return new Promise(function(resolve) {
runAll(function(overallStatus) {
runAll(function(jasmineDoneInfo) {
if (onComplete) {
onComplete();
}
resolve(overallStatus);
resolve(jasmineDoneInfo);
});
});
@@ -1956,19 +1956,17 @@ getJasmineRequireObj().Env = function(j$) {
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
* @since 2.4.0
*/
reporter.jasmineDone(
{
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
},
function() {
done(overallStatus);
}
);
const jasmineDoneInfo = {
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
};
reporter.jasmineDone(jasmineDoneInfo, function() {
done(jasmineDoneInfo);
});
});
}
);

View File

@@ -31,8 +31,8 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
const overallStatus = await env.execute();
expect(overallStatus).toEqual('passed');
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('allows adding more strategies local to a spec', async function() {
@@ -51,8 +51,8 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
const overallStatus = await env.execute();
expect(overallStatus).toEqual('passed');
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('allows using custom strategies on a per-argument basis', async function() {
@@ -77,8 +77,8 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
const overallStatus = await env.execute();
expect(overallStatus).toEqual('passed');
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('allows multiple custom strategies to be used', async function() {
@@ -112,8 +112,8 @@ describe('Custom Spy Strategies (Integration)', function() {
});
env.addReporter({ specDone: specDone });
const overallStatus = await env.execute();
expect(overallStatus).toEqual('passed');
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
expect(specDone.calls.count()).toBe(2);
});
});

View File

@@ -29,8 +29,8 @@ describe('Default Spy Strategy (Integration)', function() {
expect(spy()).toBeUndefined();
});
const overallStatus = await env.execute();
expect(overallStatus).toEqual('passed');
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
it('uses the default spy strategy defined when the spy is created', async function() {
@@ -60,7 +60,7 @@ describe('Default Spy Strategy (Integration)', function() {
expect(d.and.isConfigured()).toBe(false);
});
const overallStatus = await env.execute();
expect(overallStatus).toEqual('passed');
const result = await env.execute();
expect(result.overallStatus).toEqual('passed');
});
});

View File

@@ -3229,14 +3229,21 @@ describe('Env integration', function() {
});
});
it('is resolved to the overall status', function() {
it('is resolved to the value of the jasmineDone event', async function() {
env.describe('suite', function() {
env.it('spec', function() {
env.expect(true).toBe(false);
});
});
return expectAsync(env.execute(null)).toBeResolvedTo('failed');
let event;
env.addReporter({
jasmineDone: e => (event = e)
});
const result = await env.execute();
expect(event.overallStatus).toEqual('failed');
expect(result).toEqual(event);
});
});

View File

@@ -749,12 +749,12 @@ getJasmineRequireObj().Env = function(j$) {
jasmineTimer.start();
return new Promise(function(resolve) {
runAll(function(overallStatus) {
runAll(function(jasmineDoneInfo) {
if (onComplete) {
onComplete();
}
resolve(overallStatus);
resolve(jasmineDoneInfo);
});
});
@@ -805,19 +805,17 @@ getJasmineRequireObj().Env = function(j$) {
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
* @since 2.4.0
*/
reporter.jasmineDone(
{
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
},
function() {
done(overallStatus);
}
);
const jasmineDoneInfo = {
overallStatus: overallStatus,
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
order: order,
failedExpectations: topSuite.result.failedExpectations,
deprecationWarnings: topSuite.result.deprecationWarnings
};
reporter.jasmineDone(jasmineDoneInfo, function() {
done(jasmineDoneInfo);
});
});
}
);