From 48560bf52fa9d587f302d4d8512e7f7c8038f8c5 Mon Sep 17 00:00:00 2001 From: Jiri Spac Date: Wed, 28 Feb 2018 22:36:34 +0200 Subject: [PATCH] fixes #5531 (#5532) because we can have a "describe" block but no "it" blocks inside --- .../jest-jasmine2/src/__tests__/Suite.test.js | 27 +++++++++++++++++++ packages/jest-jasmine2/src/jasmine/Suite.js | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 packages/jest-jasmine2/src/__tests__/Suite.test.js diff --git a/packages/jest-jasmine2/src/__tests__/Suite.test.js b/packages/jest-jasmine2/src/__tests__/Suite.test.js new file mode 100644 index 000000000000..800f30146ab3 --- /dev/null +++ b/packages/jest-jasmine2/src/__tests__/Suite.test.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +'use strict'; + +import Suite from '../jasmine/Suite'; + +describe('Suite', () => { + let suite; + + beforeEach(() => { + suite = new Suite({ + getTestPath: () => '', + }); + }); + + it("doesn't throw on addExpectationResult when there are no children", () => { + expect(() => { + suite.addExpectationResult(); + }).not.toThrow(); + }); +}); diff --git a/packages/jest-jasmine2/src/jasmine/Suite.js b/packages/jest-jasmine2/src/jasmine/Suite.js index bf5910ed6550..e37ee5e99c80 100644 --- a/packages/jest-jasmine2/src/jasmine/Suite.js +++ b/packages/jest-jasmine2/src/jasmine/Suite.js @@ -210,7 +210,7 @@ function convertDescriptorToString(descriptor) { } function isAfterAll(children) { - return children && children[0].result.status; + return children && children[0] && children[0].result.status; } function isFailure(args) {