Adds new configuration option to failSpecWithNoExpectations that will report specs without expectations as failures if enabled

This commit is contained in:
Dmitriy T
2019-08-22 16:08:43 -04:00
committed by Steve Gravrock
parent e8870db8d3
commit 7263a38c3f
9 changed files with 172 additions and 48 deletions

View File

@@ -296,7 +296,7 @@ describe('TreeProcessor', function() {
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
expect(leaf.execute).toHaveBeenCalledWith('foo', false);
expect(leaf.execute).toHaveBeenCalledWith('foo', false, false);
});
it('runs a node with no children', function() {
@@ -368,10 +368,10 @@ describe('TreeProcessor', function() {
expect(queueableFns.length).toBe(3);
queueableFns[1].fn('foo');
expect(leaf1.execute).toHaveBeenCalledWith('foo', false);
expect(leaf1.execute).toHaveBeenCalledWith('foo', false, false);
queueableFns[2].fn('bar');
expect(leaf2.execute).toHaveBeenCalledWith('bar', false);
expect(leaf2.execute).toHaveBeenCalledWith('bar', false, false);
});
it('cascades errors up the tree', function() {
@@ -397,7 +397,7 @@ describe('TreeProcessor', function() {
expect(queueableFns.length).toBe(2);
queueableFns[1].fn('foo');
expect(leaf.execute).toHaveBeenCalledWith('foo', false);
expect(leaf.execute).toHaveBeenCalledWith('foo', false, false);
queueRunner.calls.mostRecent().args[0].onComplete('things');
expect(nodeComplete).toHaveBeenCalled();
@@ -433,7 +433,7 @@ describe('TreeProcessor', function() {
expect(nodeStart).toHaveBeenCalledWith(node, 'bar');
queueableFns[1].fn('foo');
expect(leaf1.execute).toHaveBeenCalledWith('foo', true);
expect(leaf1.execute).toHaveBeenCalledWith('foo', true, false);
node.getResult.and.returnValue({ im: 'disabled' });
@@ -445,6 +445,35 @@ describe('TreeProcessor', function() {
);
});
it('should execute node with correct arguments when failSpecWithNoExpectations option is set', function() {
var leaf = new Leaf(),
node = new Node({ children: [leaf] }),
root = new Node({ children: [node] }),
queueRunner = jasmine.createSpy('queueRunner'),
nodeStart = jasmine.createSpy('nodeStart'),
nodeComplete = jasmine.createSpy('nodeComplete'),
processor = new jasmineUnderTest.TreeProcessor({
tree: root,
runnableIds: [],
queueRunnerFactory: queueRunner,
nodeStart: nodeStart,
nodeComplete: nodeComplete,
failSpecWithNoExpectations: true
}),
treeComplete = jasmine.createSpy('treeComplete'),
nodeDone = jasmine.createSpy('nodeDone');
processor.execute(treeComplete);
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
queueableFns[0].fn(nodeDone);
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
expect(queueableFns.length).toBe(2);
queueableFns[1].fn('foo');
expect(leaf.execute).toHaveBeenCalledWith('foo', true, true);
});
it('runs beforeAlls for a node with children', function() {
var leaf = new Leaf(),
node = new Node({
@@ -600,11 +629,11 @@ describe('TreeProcessor', function() {
queueableFns[0].fn();
expect(nonSpecified.execute).not.toHaveBeenCalled();
expect(specified.execute).toHaveBeenCalledWith(undefined, false);
expect(specified.execute).toHaveBeenCalledWith(undefined, false, false);
queueableFns[1].fn();
expect(nonSpecified.execute).toHaveBeenCalledWith(undefined, true);
expect(nonSpecified.execute).toHaveBeenCalledWith(undefined, true, false);
});
it('runs nodes and leaves with a specified order', function() {

View File

@@ -2138,6 +2138,41 @@ describe("Env integration", function() {
});
});
describe('when spec has no expectations', function() {
var env, reporter;
beforeEach(function() {
env = new jasmineUnderTest.Env();
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
env.addReporter(reporter);
env.it('is a spec without any expectations', function() {
// does nothing, just a mock spec without expectations
});
});
it('should report "failed" status if "failSpecWithNoExpectations" is enabled', function(done) {
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('failed');
done();
});
env.configure({ failSpecWithNoExpectations: true });
env.execute();
});
it('should report "passed" status if "failSpecWithNoExpectations" is disabled', function(done) {
reporter.jasmineDone.and.callFake(function(e) {
expect(e.overallStatus).toEqual('passed');
done();
});
env.configure({ failSpecWithNoExpectations: false });
env.execute();
});
});
describe('When a top-level beforeAll fails', function() {
it('is "failed"', function(done) {
var env = new jasmineUnderTest.Env(),