Skip to content

fix(jest): Explicitly import MockApiClient in container.spec.tsx#115780

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/jest-mockapiclient-import
Draft

fix(jest): Explicitly import MockApiClient in container.spec.tsx#115780
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/jest-mockapiclient-import

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented May 19, 2026

This PR addresses a `ReferenceError: MockApiClient is not defined` occurring in `static/app/components/pageFilters/container.spec.tsx`.

Root Cause: The test file was implicitly relying on MockApiClient being a global variable, which is typically set up in tests/js/setup.ts. However, in certain CI environments or specific test execution contexts, this global was not reliably available for this particular spec file, leading to the ReferenceError.

Fix: An explicit import import {Client as MockApiClient} from 'sentry/api'; has been added to static/app/components/pageFilters/container.spec.tsx. This ensures that MockApiClient is always defined within the scope of the test file.

Jest's auto-mocking mechanism will correctly resolve sentry/api to the mocked client defined in static/app/__mocks__/api.tsx, preserving the intended test behavior for MockApiClient.clearMockResponses() and MockApiClient.addMockResponse() while eliminating the ReferenceError.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes JEST-2E0G

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.56%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants