From 04b4c8c5832f078d9d220016b5598cd17cb0d946 Mon Sep 17 00:00:00 2001 From: Song Xie Date: Tue, 15 Aug 2017 01:12:14 -0700 Subject: [PATCH] Include fullName in formattedAssertion (#4273) --- .../src/__tests__/format_test_results_test.js | 37 +++++++++++++++++++ packages/jest-util/src/format_test_results.js | 1 + types/TestResult.js | 3 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 packages/jest-util/src/__tests__/format_test_results_test.js diff --git a/packages/jest-util/src/__tests__/format_test_results_test.js b/packages/jest-util/src/__tests__/format_test_results_test.js new file mode 100644 index 000000000000..42a970f5ab0a --- /dev/null +++ b/packages/jest-util/src/__tests__/format_test_results_test.js @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +const formatTestResults = require('../formatTestResults'); + +describe('formatTestResults', () => { + const assertion = { + fullName: 'TestedModule#aMethod when some condition is met returns true', + status: 'passed', + title: 'returns true', + }; + + const results = { + testResults: [ + { + numFailingTests: 0, + perfStats: {end: 2, start: 1}, + testResults: [assertion], + }, + ], + }; + + it('includes test full name', () => { + const result = formatTestResults(results, null, null); + expect(result.testResults[0].assertionResults[0].fullName).toEqual( + assertion.fullName, + ); + }); +}); diff --git a/packages/jest-util/src/format_test_results.js b/packages/jest-util/src/format_test_results.js index 2fd80a272f2a..4ce2ddfad20f 100644 --- a/packages/jest-util/src/format_test_results.js +++ b/packages/jest-util/src/format_test_results.js @@ -61,6 +61,7 @@ function formatTestAssertion( ): FormattedAssertionResult { const result: FormattedAssertionResult = { failureMessages: null, + fullName: assertion.fullName, status: assertion.status, title: assertion.title, }; diff --git a/types/TestResult.js b/types/TestResult.js index 80e795b471ed..d2d133ad7c2a 100644 --- a/types/TestResult.js +++ b/types/TestResult.js @@ -94,9 +94,10 @@ export type AssertionResult = {| |}; export type FormattedAssertionResult = { + failureMessages: Array | null, + fullName: string, status: Status, title: string, - failureMessages: Array | null, }; export type AggregatedResultWithoutCoverage = {