Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest-jasmine2: fix describe return value warning being shown if describe throws #8335

Merged
merged 2 commits into from Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@
- `[@jest/runtime, @jest/transform]` Allow custom transforms for JSON dependencies ([#2578](https://github.com/facebook/jest/pull/2578))
- `[jest-core]` Make `detectOpenHandles` imply `runInBand` ([#8283](https://github.com/facebook/jest/pull/8283))
- `[jest-haste-map]` Fix the `mapper` option which was incorrectly ignored ([#8299](https://github.com/facebook/jest/pull/8299))
- `[jest-jasmine2]` Fix describe return value warning being shown if the describe function throws ([#8335](https://github.com/facebook/jest/pull/8335))

### Chore & Maintenance

Expand Down
8 changes: 8 additions & 0 deletions e2e/__tests__/declarationErrors.test.ts
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
@@ -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
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