Parallel: Fixed reporting of exceptions thrown by a describe
This commit is contained in:
@@ -1637,6 +1637,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
this.parallelReset = function() {
|
this.parallelReset = function() {
|
||||||
// TODO: ensure that autoCleanClosures was false
|
// TODO: ensure that autoCleanClosures was false
|
||||||
suiteBuilder.parallelReset();
|
suiteBuilder.parallelReset();
|
||||||
|
runner.parallelReset();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8422,6 +8423,10 @@ getJasmineRequireObj().Runner = function(j$) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parallelReset() {
|
||||||
|
this.executedBefore_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
async execute(runablesToRun) {
|
async execute(runablesToRun) {
|
||||||
if (this.executedBefore_) {
|
if (this.executedBefore_) {
|
||||||
this.topSuite_.reset();
|
this.topSuite_.reset();
|
||||||
@@ -9878,6 +9883,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
|||||||
|
|
||||||
parallelReset() {
|
parallelReset() {
|
||||||
this.topSuite.removeChildren();
|
this.topSuite.removeChildren();
|
||||||
|
this.topSuite.reset();
|
||||||
this.totalSpecsDefined = 0;
|
this.totalSpecsDefined = 0;
|
||||||
this.focusedRunables = [];
|
this.focusedRunables = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -592,6 +592,14 @@ describe('Env', function() {
|
|||||||
expect(id).toEqual(env.topSuite().id);
|
expect(id).toEqual(env.topSuite().id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not reset the topSuite if parallelReset was called since the last run', async function() {
|
||||||
|
await env.execute();
|
||||||
|
env.parallelReset();
|
||||||
|
spyOn(jasmineUnderTest.Suite.prototype, 'reset');
|
||||||
|
await env.execute();
|
||||||
|
expect(jasmineUnderTest.Suite.prototype.reset).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#spyOnGlobalErrorsAsync', function() {
|
describe('#spyOnGlobalErrorsAsync', function() {
|
||||||
|
|||||||
@@ -177,6 +177,26 @@ describe('SuiteBuilder', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('#parallelReset', function() {
|
describe('#parallelReset', function() {
|
||||||
|
it('resets the top suite result', function() {
|
||||||
|
jasmineUnderTest.Suite.prototype.handleException.and.callThrough();
|
||||||
|
|
||||||
|
const env = { configuration: () => ({}) };
|
||||||
|
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||||
|
|
||||||
|
suiteBuilder.topSuite.handleException(new Error('nope'));
|
||||||
|
suiteBuilder.parallelReset();
|
||||||
|
|
||||||
|
expect(suiteBuilder.topSuite.result).toEqual({
|
||||||
|
id: suiteBuilder.topSuite.id,
|
||||||
|
description: 'Jasmine__TopLevel__Suite',
|
||||||
|
fullName: '',
|
||||||
|
failedExpectations: [],
|
||||||
|
deprecationWarnings: [],
|
||||||
|
duration: null,
|
||||||
|
properties: null
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('removes children of the top suite', function() {
|
it('removes children of the top suite', function() {
|
||||||
const env = { configuration: () => ({}) };
|
const env = { configuration: () => ({}) };
|
||||||
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
const suiteBuilder = new jasmineUnderTest.SuiteBuilder({ env });
|
||||||
|
|||||||
@@ -101,4 +101,62 @@ describe('Support for parallel execution', function() {
|
|||||||
jasmine.objectContaining({ overallStatus: 'passed' })
|
jasmine.objectContaining({ overallStatus: 'passed' })
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reports errors thrown from describe', async function() {
|
||||||
|
const reporter = jasmine.createSpyObj('reporter', ['suiteDone']);
|
||||||
|
env.addReporter(reporter);
|
||||||
|
|
||||||
|
env.describe('borken', function() {
|
||||||
|
throw new Error('nope');
|
||||||
|
});
|
||||||
|
await env.execute();
|
||||||
|
|
||||||
|
expect(reporter.suiteDone).toHaveBeenCalledWith(
|
||||||
|
jasmine.objectContaining({
|
||||||
|
description: 'borken',
|
||||||
|
status: 'failed',
|
||||||
|
failedExpectations: [
|
||||||
|
jasmine.objectContaining({
|
||||||
|
message: jasmine.stringContaining('Error: nope')
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Errors in subsequent suites should also be reported
|
||||||
|
reporter.suiteDone.calls.reset();
|
||||||
|
env.parallelReset();
|
||||||
|
env.describe('zarro boogs', function() {
|
||||||
|
throw new Error('nor that either');
|
||||||
|
});
|
||||||
|
await env.execute();
|
||||||
|
|
||||||
|
expect(reporter.suiteDone).toHaveBeenCalledOnceWith(
|
||||||
|
jasmine.objectContaining({
|
||||||
|
description: 'zarro boogs',
|
||||||
|
status: 'failed',
|
||||||
|
failedExpectations: [
|
||||||
|
jasmine.objectContaining({
|
||||||
|
message: jasmine.stringContaining('Error: nor that either')
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Failure state should not persist across resets
|
||||||
|
reporter.suiteDone.calls.reset();
|
||||||
|
env.parallelReset();
|
||||||
|
env.describe('actually works', function() {
|
||||||
|
env.it('a spec', function() {});
|
||||||
|
});
|
||||||
|
await env.execute();
|
||||||
|
|
||||||
|
expect(reporter.suiteDone).toHaveBeenCalledOnceWith(
|
||||||
|
jasmine.objectContaining({
|
||||||
|
description: 'actually works',
|
||||||
|
status: 'passed',
|
||||||
|
failedExpectations: []
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -495,6 +495,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
this.parallelReset = function() {
|
this.parallelReset = function() {
|
||||||
// TODO: ensure that autoCleanClosures was false
|
// TODO: ensure that autoCleanClosures was false
|
||||||
suiteBuilder.parallelReset();
|
suiteBuilder.parallelReset();
|
||||||
|
runner.parallelReset();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ getJasmineRequireObj().Runner = function(j$) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parallelReset() {
|
||||||
|
this.executedBefore_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
async execute(runablesToRun) {
|
async execute(runablesToRun) {
|
||||||
if (this.executedBefore_) {
|
if (this.executedBefore_) {
|
||||||
this.topSuite_.reset();
|
this.topSuite_.reset();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
|||||||
|
|
||||||
parallelReset() {
|
parallelReset() {
|
||||||
this.topSuite.removeChildren();
|
this.topSuite.removeChildren();
|
||||||
|
this.topSuite.reset();
|
||||||
this.totalSpecsDefined = 0;
|
this.totalSpecsDefined = 0;
|
||||||
this.focusedRunables = [];
|
this.focusedRunables = [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user