From faadbfe5c5d1a2468a2f6f58dd295d44cd1a3c44 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Thu, 31 Oct 2024 13:01:21 -0500 Subject: [PATCH] test: add option to skip display name check --- .../react/src/BranchName/__tests__/BranchName.test.tsx | 7 ++++++- packages/react/src/utils/testing.tsx | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/react/src/BranchName/__tests__/BranchName.test.tsx b/packages/react/src/BranchName/__tests__/BranchName.test.tsx index 3687f591194..4a9445e1421 100644 --- a/packages/react/src/BranchName/__tests__/BranchName.test.tsx +++ b/packages/react/src/BranchName/__tests__/BranchName.test.tsx @@ -6,7 +6,12 @@ import axe from 'axe-core' import {FeatureFlags} from '../../FeatureFlags' describe('BranchName', () => { - behavesAsComponent({Component: BranchName}) + behavesAsComponent({ + Component: BranchName, + options: { + skipDisplayName: true, + }, + }) checkExports('BranchName', { default: BranchName, diff --git a/packages/react/src/utils/testing.tsx b/packages/react/src/utils/testing.tsx index 5f5f1caa257..5699aa85ca1 100644 --- a/packages/react/src/utils/testing.tsx +++ b/packages/react/src/utils/testing.tsx @@ -193,6 +193,7 @@ export function unloadCSS(path: string) { interface Options { skipAs?: boolean skipSx?: boolean + skipDisplayName?: boolean } interface BehavesAsComponent { @@ -221,9 +222,11 @@ export function behavesAsComponent({Component, toRender, options}: BehavesAsComp }) } - it('sets a valid displayName', () => { - expect(Component.displayName).toMatch(COMPONENT_DISPLAY_NAME_REGEX) - }) + if (!options.skipDisplayName) { + it('sets a valid displayName', () => { + expect(Component.displayName).toMatch(COMPONENT_DISPLAY_NAME_REGEX) + }) + } } // eslint-disable-next-line @typescript-eslint/no-explicit-any