/* * Split from register-anvil2.test.tsx because register.tsx changed from * dynamic require() to static `import * as` for Vite/ESM compatibility. * The previous approach used jest.resetModules() mid-file to re-mock * modules between tests, but static imports are resolved once at module * load time and aren't affected by resetModules. Separate files give * each test suite its own jest.mock declarations. */ import '@testing-library/jest-dom'; import { within } from '@testing-library/react'; import { createRegisterHarness, optionalLibraryWrappers, } from '../__mocks__/register-anvil2-harness'; jest.mock('@servicetitan/anvil2', () => ({})); jest.mock('@servicetitan/design-system', () => ({})); describe('[web-components] register', () => { const { Page, subject } = createRegisterHarness('mock-no-optional-deps'); for (const [library, wrappers] of Object.entries(optionalLibraryWrappers)) { describe(`when ${library} is not present`, () => { test.each(wrappers)('does not wrap component within %s', name => { subject(); const element = within(Page.componentShadowRoot as any).queryByText(`<${name}>`); expect(element).not.toBeInTheDocument(); }); }); } });