Skip to content

MPT-26825 declare the test globals for ts-jest - #146

Merged
svazquezco merged 1 commit into
mainfrom
bugfix/MPT-26825/declare-test-globals-ts-jest
Oct 27, 2026
Merged

svazquezco merged 1 commit into
mainfrom
bugfix/MPT-26825/declare-test-globals-ts-jest

Conversation

@svazquezco

@svazquezco svazquezco commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 AI-generated PR — Please review carefully.

First of three stacked PRs for MPT-26825. This one carries no feature change; it unblocks the other two.

What

ts-jest compiles each test file with its own program and drops the automatic @types/* inclusion, so whichever suite jest compiles first fails to type-check with TS2304: Cannot find name 'jest'. Declaring the test globals in the transform's tsconfig makes every suite compile whatever order jest runs them in.

The problem is latent in the template rather than new: any suite fails the same way when it is the first one compiled, which is reproducible today with

docker compose -f compose.yaml run --rm frontend bash -c "npm ci && npx jest src/shared/hooks/useAgreementId.test.ts"

It surfaces now because jest's default sequencer runs the largest test file first, and the deferrable example on top of this stack makes useAgreementSync.test.ts that file.

Tests

make check-all — 40 backend tests, 42 frontend tests.

Closes MPT-26825

  • Configure ts-jest to include the jest and @testing-library/jest-dom types.
  • This lets test files compile with test globals regardless of Jest’s compilation order.

ts-jest compiles each test file with its own program and drops the automatic
`@types/*` inclusion, so whichever suite jest compiles first fails to type-check
with "Cannot find name 'jest'". Declaring the globals in the transform's tsconfig
makes every suite compile whatever order jest runs them in.

The problem is latent in the template rather than new: any suite fails the same
way when it is the first one compiled. It surfaces now because jest's default
sequencer runs the largest test file first, and the deferrable example makes
`useAgreementSync.test.ts` that file.
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

✅ Found Jira issue key in the title: MPT-26825

Generated by 🚫 dangerJS against 2e403de

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 72cfc3d and 2e403de.

Files selected for processing: 1
  • frontend/jest.config.cjs
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Recent review details
Additional context used
Path-based instructions: 1
For each subsequent commit in this PR, explicitly verify if previous review comments have been resolved

CodeRabbit configuration file

Files:

  • frontend/jest.config.cjs
Multi-repo context softwareone-platform/mpt-extension-skills

Linked repositories findings

softwareone-platform/mpt-extension-skills

  • Frontend tests are standardized on Jest, Testing Library, and jsdom. [::softwareone-platform/mpt-extension-skills::standards/extensions-ui-testing-best-practices.md:10-11]
  • Strict TypeScript must remain enabled, and the type-check/lint gate must pass. [::softwareone-platform/mpt-extension-skills::standards/extensions-ui-best-practices.md:220-226]
  • No shared ts-jest configuration, exported API, or consumer references were found.
Additional comments: 1
frontend/jest.config.cjs: 1

10-16: LGTM!

Walkthrough

The Jest TypeScript transform now explicitly includes the jest and @testing-library/jest-dom type packages. The configuration retains esModuleInterop.

Changes: Jest type configuration

Layer / File(s) Summary
Set TypeScript transform types
frontend/jest.config.cjs
The transform specifies the jest and @testing-library/jest-dom type packages. It retains esModuleInterop.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: Minimal · up to 2e403

No actionable merge-blocking risk remains.

Pre-merge checks: Passed 3
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Documentation Up To Date Passed PASS — The PR changes only frontend/jest.config.cjs in the Jest/ts-jest test toolchain (lines 10–16). It declares test globals for per-file compilation and does not change application behavior, test…
Full details: Documentation Up To Date

Explanation

PASS — The PR changes only frontend/jest.config.cjs in the Jest/ts-jest test toolchain (lines 10–16). It declares test globals for per-file compilation and does not change application behavior, test scope, developer workflow, deployment configuration, or a public command. The repository testing guide already documents the frontend test commands and scope in docs/testing.md (lines 12–43, 86–98). Under the check's explicit test-only exception, no additional documentation update is required.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@svazquezco

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@svazquezco

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@svazquezco
svazquezco merged commit 9e7d1ce into main Oct 27, 2026
9 checks passed
@svazquezco
svazquezco deleted the bugfix/MPT-26825/declare-test-globals-ts-jest branch October 27, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants