Skip to content

Commit

Permalink
fix describe return value warning being shown if describe throws
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Apr 15, 2019
1 parent 2db8852 commit 67b5715
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions e2e/__tests__/declarationErrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ it('warns if describe returns something', () => {
expect(result.status).toBe(0);
expect(normalizeCircusJasmine(result.stdout)).toMatchSnapshot();
});

it('errors if describe throws', () => {
const result = runJest('declaration-errors', ['describeThrow.test.js']);

expect(result.status).toBe(1);
expect(result.stdout).toBe('');
expect(result.stderr).toContain('whoops');
});
14 changes: 14 additions & 0 deletions e2e/declaration-errors/__tests__/describeThrow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. 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';

describe('describe throw does not warn', () => {
it('t', () => {});
throw new Error('whoops');
});
4 changes: 2 additions & 2 deletions packages/jest-jasmine2/src/jasmine/Env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ export default function(j$: Jasmine) {
parentSuite.addChild(suite);
currentDeclarationSuite = suite;

let declarationError: null | Error = null;
let describeReturnValue: null | Error = null;
let declarationError: undefined | Error = undefined;
let describeReturnValue: undefined | Error = undefined;
try {
describeReturnValue = specDefinitions.call(suite);
} catch (e) {
Expand Down

0 comments on commit 67b5715

Please sign in to comment.