mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
22002bb70c
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53912 Changelog: [Internal] Add new fantom flag `fantom_disable_coverage` to be used in tests that are sensitive to things like memory allocation. Also disable coverage for any benchmark test. Reviewed By: arushikesarwani94 Differential Revision: D83070065 fbshipit-source-id: a885e79e3d0c88cfb7adef30cb60ab46a617edac
36 lines
867 B
JavaScript
36 lines
867 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
// $FlowExpectedError[untyped-import]
|
|
import {extract, parse} from 'jest-docblock';
|
|
|
|
type DocblockPragmas = {[key: string]: string | string[]};
|
|
|
|
const FANTOM_BENCHMARK_FILENAME_RE = /[Bb]enchmark-itest\./g;
|
|
|
|
export function shouldCollectCoverage(
|
|
testPath: string,
|
|
testContents: string,
|
|
globalConfig: {collectCoverage: boolean, ...},
|
|
): boolean {
|
|
if (FANTOM_BENCHMARK_FILENAME_RE.test(testPath)) {
|
|
return false;
|
|
}
|
|
|
|
const docblock = extract(testContents);
|
|
const pragmas = parse(docblock) as DocblockPragmas;
|
|
|
|
if (pragmas.fantom_disable_coverage != null) {
|
|
return false;
|
|
}
|
|
|
|
return globalConfig.collectCoverage;
|
|
}
|